cancel
Showing results for 
Search instead for 
Did you mean: 

How to emit event from CAP to a specific topic

JulianKuipers
Participant

Hi,

I want to emit and receive events from SAP Event Mesh in my CAP app. We have a dedicated queue for the topic where the events will be emitted to from the CAP app and a dedicated queue for the topic where I'll need to receive the events from.

My service definition:

service Service { 

// Events @topic: 'a/b/c/triggered' 

event triggered : { ID : UUID; parameters : { a : String(2); b: array of String(4); c : array of String(7) } } }

My service logic:

const messaging_receiving = await cds.connect.to("messaging-receiving"); 

const messaging_publishing = await cds.connect.to("messaging-publishing"); 

this.after("CREATE", "Runs", async (each) => { 

const sA = ""; 

const aB = []; 

const aC = []; 

const oPayLoad = { ID: sInterfaceRunID, parameters: { a: sA, b: aB, c: aC, }, }; 

await messaging_publishing.emit( "a/b/c/triggered", oPayLoad ); } });

My cds.requires:

"cds": {
"requires" : {

"messaging-receiving": {
          "kind": "enterprise-messaging-shared",
          "publishPrefix": "$namespace/",
          "subscribePrefix": "$namespace/",
          "format": "cloudevents",
          "queue": {
            "name": "$namespace/v1/flowStatus"
          }
        },
        "messaging-publishing": {
          "kind": "enterprise-messaging-shared",
          "publishPrefix": "$namespace/",
          "subscribePrefix": "$namespace/",
          "format": "cloudevents",
          "queue": {
            "name": "$namespace/v1/startFlow"
          }
        }
}
}<br>

The automatic creation of queues and topics is visible in the SAP Event Mesh. I'm able to receive events, but the ones I emit aren't showing up in the SAP Event Mesh. Any idea what I might be missing?

Kind regards,

Julian

View Entire Topic
JulianKuipers
Participant
0 Kudos

We've fixed this issue by updaring @sap/cds from version 7.3.1. to version 7.4.1.