Using SAP Cloud Application Event Hub in Cloud Foundry
SAP Cloud Application Event Hub is the new default offering for messaging in SAP Business Technology Platform (SAP BTP). CAP provides out-of-the-box support for SAP Cloud Application Event Hub, and automatically handles many things behind the scenes, so that application coding stays agnostic and focused on conceptual messaging.
WARNING
The following guide is based on a productive (paid) account on SAP BTP.
Consuming Events in a Stand-alone App
This guide describes the end-to-end process of developing a stand-alone (or "single tenant") CAP application that consumes messages via SAP Cloud Application Event Hub. The guide uses SAP S/4HANA as the event emitter, but this is a stand-in for any system that is able to publish CloudEvents via SAP Cloud Application Event Hub.
Sample app: @capire/incidents with Customers based on S/4's Business Partners
Prerequisite: Events & Messaging in CAP
From the perspective of a CAP developer, SAP Cloud Application Event Hub is yet another messaging broker. That is to say, CAP developers focus on modeling their domain and implementing their domain-specific custom logic. Differences between the various event transporting technologies are held as transparent as possible.
Hence, before diving into this guide, you should be familiar with the general guide for Events & Messaging in CAP, as it already covers the majority of the content.
Since SAP Cloud Application Event Hub is based on the CloudEvents standard, the @topic
annotation for events in your CDS model is interpreted as the CloudEvents type
attribute.
Add Events and Handlers
There are two options for adding the events that shall be consumed to your model, and subsequently registering event handlers for the same.
1. Import and Augment
This approach is described in Events from SAP S/4HANA, Receiving Events from SAP S/4HANA Cloud Systems, and specifically Consume Events Agnostically regarding handler registration.
2. Using Low-Level Messaging
As a second option, you can skip the modeling part and simply use Low-Level Messaging. However, please note that future Open Resource Discovery (ORD) integration will most likely benefit from modeled approaches.
Use event-broker
Configure your application to use the messaging service kind event-broker
(derived from SAP Cloud Application Event Hub's technical name).
Learn more about configuring SAP Cloud Application Event Hub in CAP Node.js
Learn more about cds.env
profiles
Local Testing
Since SAP Cloud Application Event Hub sends events via HTTP, you won't be able to receive events on your local machine unless you use a tunneling service. Therefore we recommend to use a messaging service of kind local-messaging
for local testing.
Deploy to the Cloud (with MTA)
Please see Deploy to Cloud Foundry regarding deployment with MTA as well as the deployment section from SAP Cloud Application Event Hub in CAP Node.js.
Connecting it All Together
In SAP BTP System Landscape, add a new system of type SAP BTP Application
for your CAP application including its integration dependencies, connect all involved systems (incl. SAP Cloud Application Event Hub) into a formation and enable the event subscription.
For more details, please refer to guide CAP Application as a Consumer in the official documentation of SAP Cloud Application Event Hub.
Test Events
For testing purposes, SAP S/4HANA can send technical test events of type sap.eee.iwxbe.testproducer.v1.Event.Created.v1
which your app can subscribe to. You can trigger such events with Enterprise Event Enablement - Event Monitor.