cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CAP Java: Config for Event Messaging with Message Queuing

simondold67
Product and Topic Expert
Product and Topic Expert
0 Kudos
2,059

Hello,

I'm currently learning CAP Java and trying to implement an event messaging service using the Message Queue Message Broker.

Before I can use the broker I have to configure it in my application.yaml file. (as described in the cap documentation)

I did this as follows:

spring:
config.activate.on-profile: default
cds:
messaging.services:
- name: "messaging"
kind: "message-queuing"

Whenever I try to start the application I get the following error:

***************************
APPLICATION FAILED TO START
***************************

Description:

Field messagingService in customer.message_que_send.handlers.CatalogServiceHandler required a bean of type 'com.sap.cds.services.messaging.MessagingService' that could not be found.

The injection point has the following annotations:
        - @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'com.sap.cds.services.messaging.MessagingService' in your configuration.<br>

What am I doing wrong in my config?

Or is there another problem?

Thanks for your help.

Accepted Solutions (1)

Accepted Solutions (1)

dietrich_mostowoj
Discoverer
0 Kudos

Hello Simon,

you can check the startup log of your application whether the 'messaging' service was registered and initialised properly? Did you install the MQ dependencies in your application pom:

<dependency>
  <groupId>com.sap.cds</groupId>
  <artifactId>cds-feature-message-queuing</artifactId>
  <scope>runtime</scope>
</dependency>

and be carefully with the indentations in the application.yaml:

spring:
config.activate.on-profile: default
cds:
messaging.services:
- name: "messaging"
kind: "message-queuing"

Regards,

Dietrich

simondold67
Product and Topic Expert
Product and Topic Expert
0 Kudos

Thanks for your answer!

I correctly indented the config in my application.yaml and have set the dependencies for MQ in my pom.xml.

Unfortunately I still get the error message.

Where can I see if the messaging service has been registered correctly?

I tried event messaging with file-based-messaging, this worked but with MQ I always get the error message as described above.

dietrich_mostowoj
Discoverer

In the startup log of the application you can find all services registrations.

simondold67
Product and Topic Expert
Product and Topic Expert
0 Kudos

You are right, my log says: "No service bindings with label 'message-queuing' found" what can I do to register the service correctly?

simondold67
Product and Topic Expert
Product and Topic Expert
0 Kudos

For anyone who has the same problem.

My solution was to bind the cloud service to my application. This is described in this article (Hybrid Testing): https://cap.cloud.sap/docs/advanced/hybrid-testing

First the service needs to be bound with:

cds bind -2 my-hana:my-hana-key.

After that, the application must be started as follows:

cds bind --exec mvn spring-boot:run
dietrich_mostowoj
Discoverer
0 Kudos

You need to bind the MQ service to your application, otherwise there is no messaging infrastructure.

Answers (1)

Answers (1)

MohanrajV
Discoverer
0 Kudos

can u give demo for java cap messaging please