Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cds^8.2] Event Broker: S/4HANA Cloud to CAP #1198

Merged
merged 53 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
4dca6ce
Event Broker
sjvans Aug 16, 2024
a0672d7
stash
sjvans Aug 16, 2024
e25b0ff
remove
sjvans Aug 16, 2024
05bcefc
add beta and only node.js
sjvans Aug 19, 2024
2ce2831
more
sjvans Aug 19, 2024
2d21d44
identity
sjvans Aug 19, 2024
2aae39c
fix links
sjvans Aug 19, 2024
dc16807
rm beta
sjvans Aug 20, 2024
ceef211
Prerequisite: Setup SAP Event Broker
sjvans Aug 20, 2024
416ddfd
Add Events and Handlers
sjvans Aug 20, 2024
7cbb407
ord + ias
sjvans Aug 20, 2024
bc0dcce
Merge branch 'main' into event-broker-cap
sjvans Aug 20, 2024
84b34c0
Deploy to the Cloud and more
sjvans Aug 20, 2024
8426c9b
e2e test
sjvans Aug 20, 2024
838915e
beta
sjvans Aug 20, 2024
6fe2b8b
beta
sjvans Aug 20, 2024
7f63365
SAP Event Mesh or SAP Event Broker
sjvans Aug 20, 2024
c910b64
revert change
sjvans Aug 20, 2024
a37e6a4
fix link
sjvans Aug 21, 2024
84ddc70
fix one more
sjvans Aug 21, 2024
224d651
feature matrix, learn more
sjvans Aug 21, 2024
25bd054
Update guides/messaging/event-broker.md
David-Kunz Aug 21, 2024
0f4e543
CAP always grows
David-Kunz Aug 26, 2024
8bc984a
Update guides/messaging/event-broker.md
David-Kunz Aug 26, 2024
ff06536
rm "decoupled" option
David-Kunz Aug 26, 2024
25ad6fe
rm misleading requires entry
David-Kunz Aug 26, 2024
6c3b729
fix typo in name
David-Kunz Aug 26, 2024
0d28f43
Merge branch 'main' into event-broker-cap
David-Kunz Aug 27, 2024
3aaa254
rm too much docu
David-Kunz Aug 27, 2024
f3fa527
mv mta.yaml
David-Kunz Aug 27, 2024
003a7c2
.
David-Kunz Aug 27, 2024
71dbfde
.
David-Kunz Aug 27, 2024
e3aa0a6
Merge branch 'main' into event-broker-cap
David-Kunz Aug 28, 2024
3fe7fc9
clarify singletenancy
David-Kunz Aug 28, 2024
5223357
Merge branch 'main' into event-broker-cap
David-Kunz Sep 9, 2024
0d11bcc
add tip box
David-Kunz Sep 9, 2024
7cd089d
.
David-Kunz Sep 9, 2024
4978cf7
specify cloudevents type
David-Kunz Sep 10, 2024
5980ac4
Merge branch 'main' into event-broker-cap
smahati Sep 10, 2024
ed919e2
Merge branch 'event-broker-cap' of https://github.com/cap-js/docs int…
David-Kunz Sep 12, 2024
84214ca
Merge branch 'main' into event-broker-cap
David-Kunz Sep 12, 2024
480e645
.
David-Kunz Sep 12, 2024
d71a516
.
David-Kunz Sep 17, 2024
4d8d872
.
David-Kunz Sep 19, 2024
61778ad
Merge branch 'main' into event-broker-cap
David-Kunz Sep 20, 2024
09c8b52
fix webhookpath
David-Kunz Sep 20, 2024
9f2eb23
add generic link
David-Kunz Sep 23, 2024
7c5bebd
Merge branch 'main' into event-broker-cap
David-Kunz Sep 23, 2024
4fc364f
.
David-Kunz Sep 23, 2024
2f59393
Merge branch 'main' into event-broker-cap
David-Kunz Sep 23, 2024
e19c1a4
.
David-Kunz Sep 23, 2024
56b5e50
Merge branch 'main' into event-broker-cap
renejeglinsky Sep 25, 2024
928d43c
fix link
renejeglinsky Sep 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion about/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,14 @@ Following is an index of the features currently covered by CAP, with status and
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----:|:-------:|:----:|
| [Declared Events in CDS](../cds/cdl#events) | <X/> | <X/> | <X/> |
| Mock Broker (to speed up local dev) [[Node.js](../node.js/messaging#file-based)\|[Java](../java/messaging#local-testing)] | <Na/> | <X/> | <X/> |
| SAP Event Mesh (Singletenancy) [[Node.js](../node.js/messaging#event-mesh-shared)\|[Java](../java/messaging#configuring-sap-event-mesh-support)] | <Na/> | <X/> | <X/> |
| SAP Event Mesh (For single-tenant apps) [[Node.js](../node.js/messaging#event-mesh-shared)\|[Java](../java/messaging#configuring-sap-event-mesh-support)] | <Na/> | <X/> | <X/> |
| SAP Event Broker (For single-tenant apps) [[Node.js](../node.js/messaging#event-broker)] | <Na/> | <X/><br>beta<sup>1</sup> | <D/> |
| Composite Messaging (routing by configuration) [[Node.js](../node.js/messaging#composite-messaging)\|[Java](../java/messaging#composite-messaging-service)] | <Na/> | <X/> | <X/> |
| Import AsyncAPI | <O/> | | |
| Export AsyncAPI | <X/> | | |

> <sup>1</sup> May be outsourced into a plugin, hence the status _beta_. <br>

<span id="events-messaging-more" />

### Database Support
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
195 changes: 195 additions & 0 deletions guides/messaging/event-broker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
<script setup>
import { h } from 'vue'
const X = () => h('span', { class: 'ga', title: 'Available' }, ['✓'] )
const Na = () => h('i', { class: 'na', title: 'not applicable' }, ['n/a'] )
const D = () => h('i', { class: 'prog', title: 'in progress' }, ['in prog.'] )
const O = () => h('i', { class: 'plan', title: 'planned' }, ['planned'] )
</script>
<style scoped>
.ga { color: var(--vp-c-green-2); font-weight:900;}
.na { color: #aaa; font-size:90%; }
.prog { color: var(--vp-c-green-3); font-size:90%; font-weight:500; }
.plan { color: #089; font-size:90% }
</style>



# Using SAP Event Broker in Cloud Foundry

[SAP Event Broker](https://help.sap.com/docs/event-broker) is the new default offering for messaging in SAP Business Technology Platform (SAP BTP).
CAP provides out-of-the-box support for SAP Event Broker, 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.
:::

[[toc]]

<span id="eventbrokerfeaturematrix" />



## Consuming Events in a Stand-alone App { #consume-standalone }

This guide describes the end-to-end process of developing a stand-alone (or "single tenant") CAP application that consumes messages via SAP Event Broker.
The guide uses SAP S/4HANA as the event emitter, but this is a stand-in for any system that is able to publish cloud events via SAP Event Broker.

Sample app: [@capire/incidents with Customers based on S/4's Business Partners](https://github.com/cap-js/incidents-app/tree/event-broker)


### Prerequisite: Events & Messaging in CAP

From the perspective of a CAP developer, SAP Event Broker is yet another messaging broker.
That is to say, CAP developers focus on [modeling their domain](../domain-modeling) and [implementing their domain-specific custom logic](../providing-services#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](../messaging/), as it already covers the majority of the content.


### 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](../messaging/#events-from-sap-s-4hana), [Receiving Events from SAP S/4HANA Cloud Systems](../messaging/s4), and specifically [Consume Events Agnostically](../messaging/s4#consume-events-agnostically) regarding handler registration.

#### 2. Using Low-Level Messaging

Copy link
Contributor

@David-Kunz David-Kunz Aug 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Event Broker enforces the [cloudevents](https://cloudevents.io/) standard and `@topic` refers to the cloudevents `type` property.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event manually in any service

Not true, it must be in an external service. Otherwise it's considered to be an event the app publishes.

As a second option, you can skip the modeling part and simply use [Low-Level Messaging](../messaging/s4#using-low-level-messaging).
However, please note that future [Open Resource Discovery (ORD)](https://sap.github.io/open-resource-discovery/) integration will most likely benefit from modeled approaches.


### Use `event-broker`

Configure your application to use the `event-broker` messaging service.

[Learn more about configuring SAP Event Broker in CAP Node.js](../../node.js/messaging#event-broker){.learn-more}

[Learn more about `cds.env` profiles](../../node.js/cds-env#profiles){.learn-more}

::: tip Local Testing
Since SAP Event Broker sends events via HTTP, local
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a comment so that we don't miss the incomplete sentence.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't help 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sjvans Will you complete the sentence? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sjvans Will you complete the sentence? :)

i don't know what @David-Kunz wanted to say here ;) but yes, we'll take care of it

:::


### Deploy to the Cloud (with MTA)

Please see [Deploy to Cloud Foundry](../deployment/to-cf) regarding deployment with MTA as well as the deployment section from [SAP Event Broker in CAP Node.js](../../node.js/messaging#event-broker).


### 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 Event Broker) into a formation and enable the event subscription, as described in [CAP Application as a Subscriber](https://help.sap.com/docs/event-broker/event-broker-draft-service/integration-example-using-cap-application?state=DRAFT).

::: tip 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_.
:::


<!--The following mta.yaml snippet ensures the sequential creation of the SAP Event Broker and IAS service instances, as well as binds the application to both service instances with the respectively necessary configuration.-->

<!--```yaml-->
<!--ID: cap.incidents-->
<!---->
<!--modules:-->
<!-- - name: incidents-srv-->
<!-- provides:-->
<!-- - name: incidents-srv-api-->
<!-- properties:-->
<!-- url: ${default-url} #> needed in webhookUrl and home-url below-->
<!-- requires:-->
<!-- - name: incidents-event-broker-->
<!-- parameters:-->
<!-- config:-->
<!-- authentication-type: X509_IAS-->
<!-- - name: incidents-ias-->
<!-- parameters:-->
<!-- config:-->
<!-- credential-type: X509_GENERATED-->
<!-- app-identifier: cap.incidents #> any value, e.g., reuse MTA ID-->
<!---->
<!--resources:-->
<!-- - name: incidents-event-broker-->
<!-- type: org.cloudfoundry.managed-service-->
<!-- parameters:-->
<!-- service: event-broker-->
<!-- service-plan: event-connectivity-->
<!-- config:-->
<!-- # unique identifier for this event broker instance-->
<!-- # should start with own namespace (i.e., "foo.bar") and may not be longer than 15 characters-->
<!-- systemNamespace: cap.incidents-->
<!-- webhookUrl: ~{incidents-srv-api/url}/-/cds/event-broker/webhook-->
<!-- requires:-->
<!-- - name: incidents-srv-api-->
<!-- - name: incidents-ias-->
<!-- type: org.cloudfoundry.managed-service-->
<!-- requires:-->
<!-- - name: incidents-srv-api-->
<!-- processed-after:-->
<!-- # for consumed-services (cf. below), incidents-event-broker must already exist-->
<!-- # -> ensure incidents-ias is created after incidents-event-broker-->
<!-- - incidents-event-broker-->
<!-- parameters:-->
<!-- service: identity-->
<!-- service-plan: application-->
<!-- config:-->
<!-- consumed-services:-->
<!-- - service-instance-name: incidents-event-broker-->
<!-- display-name: cap.incidents #> any value, e.g., reuse MTA ID-->
<!-- home-url: ~{incidents-srv-api/url}-->
<!--```-->
<!---->
<!--Please note that the mta.yaml snippet above is based on the sample app [@capire/incidents](https://github.com/cap-js/incidents-app/tree/event-broker), i.e., ID, module, and resource names are taken from this context and need to be adjusted.-->
<!---->
<!--The full `mta.yaml` of the sample application can be found [here](https://github.com/cap-js/incidents-app/blob/event-broker/mta.yaml).-->


<!--
- Should not be part of the guide, but rather a link to their documentation
- Test events are not treated differently, if you want to test your app, trigger an event for which you already declared integration dependencies


### End-to-End Test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That whole chapter should preferably move to the Event Broker team's deployment guide, shouldn't it?

Copy link
Contributor

@David-Kunz David-Kunz Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Their current guide is incomprehensible and doesn't provide enough information for anyone to deploy an app with IAS-based authentication, so it's good that CAP provides a sample mta.yaml file which connects all dots. There are also some CAP-specific configurations, like the webhookUrl property.
In the future, I hope we will have proper cds add event-broker and cds add identity support to cover it. But I think we should move the sample mta.yaml file to our event broker section. We did a similar thing for Event Mesh (at least the XSUAA configuration).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That being said, I dislike having S/4HANA specifics in our guide as well as instructions on how to configure systems and formations in the BTP Cockpit System Landscape.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I therefore propose:

  1. Move a link to a sample mta.yaml to the event-broker section (not this guide here), explain the necessary services (e.g. IAS) and the reasoning behind it. This guide should only reference the event broker section for specifics of its configuration & deployment.

  2. Clarify with the Event Broker colleagues that all information regarding the configuration of the system landscape and enablement of the events is properly documented in their docs. Then we can add a link to it.

  3. Same goes for instructions on how to configure S/4HANA.


You can conduct an end-to-end test of your finalized setup by executing the following steps.

#### 1. Add Integration Dependency

In BTP Cockpit &rarr; System Landscape, navigate to the system that represents your CAP application.
Add an _Integration Dependency_ using the _Simplified Business Eventing Template_ for _Event Type_ `sap.eee.iwxbe.testproducer.v1.Event.Created.v1` and _Publishing System Namespace_ `sap.s4` as shown in the following screenshot.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test event is quite prominent, shouldn't we mention that the actual to-be-consumed event types need to be declared here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, readers might be confused that it works for the test event, but not for the actual event they later might want to consume.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be part of event broker docs


![Integration Dependency for Test Event](assets/event-broker-test-integration-dependency.png)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2. Create Formation

missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, formation will already exist (event broker docs)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formation needs to be manually created

#### 2. Activate Event Subscription

In SAP Event Broker Application, activate the subscription for the added integration dependency (cf. [Enabling SAP Event Subscriptions](https://help.sap.com/docs/event-broker/event-broker-service-guide/enable-subscriptions)).

#### 3. Trigger Test Event

In S/4HANA Cloud, navigate to application _Enterprise Event Enablement - Event Monitor_ and navigate into the channel you created during setup.
On the top right, press button _Produce Test Event_.
This will add an entry in the list of _Outbound Events_ with topic `na/na/na/ce/sap/eee/iwxbe/testproducer/v1/Event/Created/v1` and, eventually, status _Acknowledged_.

#### 4. Check Application Logs

In the application logs of your CAP application, check for a log entry noting the successful event reception as shown in the following screenshot.

![Log Entry for Test Event](assets/event-broker-test-log-entry.png)

-->


<!-- TODO

### Hybrid Testing

Possible? If yes, how?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only with ngrok etc. But since webhook urls are specified as binding parameters, it's cumbersome to quickly switch them for testing. I therefore wouldn't mention it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, same thinking here. but i wanted to keep as a kind of reminder that this could be improved...


-->



<span id="eventbrokersaasconsuming" />

<span id="eventbrokersaaspublishing" />
2 changes: 1 addition & 1 deletion guides/messaging/event-mesh.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ status: released

# Using SAP Event Mesh in Cloud Foundry

[SAP Event Mesh](https://help.sap.com/docs/SAP_EM) is the default offering for messaging in SAP Business Technology Platform (SAP BTP). CAP provides out-of-the-box support for SAP Event Mesh, and automatically handles many things behind the scenes, so that application coding stays agnostic and focused on conceptual messaging.
CAP provides out-of-the-box support for [SAP Event Mesh](https://help.sap.com/docs/event-mesh), 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. It's not supported to use the trial offering of SAP Event Mesh.
Expand Down
31 changes: 29 additions & 2 deletions guides/messaging/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -577,11 +577,38 @@ Find additional information about deploying SAP Event Mesh on SAP BTP in this gu



## [Using SAP Event Broker](./event-broker) {#sap-event-broker}

CAP has growing out-of-the-box support for SAP Event Broker.
As an application developer, all you need to do is configuring CAP to use `event-broker`, as in this excerpt from a _package.json_:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's also required to have an IAS service, I think we should mention it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also just link to the event-broker section, there it's written that IAS is needed.


```jsonc
"cds": {
"requires": {
"messaging": {
"[production]": {
"kind": "event-broker"
}
}
}
}
```

[Learn more about `cds.env` profiles](../../node.js/cds-env#profiles){.learn-more}


::: tip Read the guide
Find additional information about deploying SAP Event Broper on SAP BTP in this guide:
[&rarr; **_Using SAP Event Broker in BTP_**](./event-broker)
:::



## [Events from SAP S/4HANA](./s4)
<!-- {.toc-redirect} -->

SAP S/4HANA integrates SAP Event Mesh for messaging. That makes it relatively easy
for CAP-based applications to receive events from SAP S/4HANA systems.
SAP S/4HANA integrates SAP Event Mesh as well as SAP Event Broker for messaging.
That makes it relatively easy for CAP-based applications to receive events from SAP S/4HANA systems.

In contrast to CAP, the asynchronous APIs of SAP S/4HANA are separate from the synchronous ones (OData, REST).
So, the effort on the CAP side is to fill this gap.
Expand Down
33 changes: 25 additions & 8 deletions guides/messaging/s4.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ status: released

# Receiving Events from SAP S/4HANA Cloud Systems

SAP S/4HANA integrates SAP Event Mesh for messaging, hence it's relatively easy
for CAP-based application to receive events from SAP S/4HANA systems.
SAP S/4HANA integrates SAP Event Mesh as well as SAP Event Broker for messaging.
Hence, it is relatively easy for CAP-based application to receive events from SAP S/4HANA systems.
This guide provides detailed information on that.

::: tip See also:
Expand Down Expand Up @@ -86,9 +86,12 @@ S4bupa.on ('BusinessPartner.Changed', msg => {...})
```


## Configure SAP Event Mesh
## Configure CAP

To ease the pain of the afore-mentioned topic rewriting effects, CAP has built-in support for [SAP Event Mesh](./event-mesh). Configure the messaging service as follows, to let it automatically create correct technical topics to subscribe to SAP S/4HANA events:
To ease the pain of the afore-mentioned topic rewriting effects, CAP has built-in support for [SAP Event Mesh](./event-mesh) as well as [SAP Event Broker](./event-broker).
Configure the messaging service as follows, to let it automatically create correct technical topics to subscribe to SAP S/4HANA events:

For SAP Event Mesh:

```json
"cds": {
Expand All @@ -106,6 +109,18 @@ To ease the pain of the afore-mentioned topic rewriting effects, CAP has built-i

**Note:** In contrast to the default configuration recommended in the [SAP Event Mesh documentation](https://help.sap.com/docs/SAP_EM/bf82e6b26456494cbdd197057c09979f/5499e2e74e674c69b057072272c80d4f.html), ensure you configure your service instance to allow the pattern `+/+/+/ce/*` for subscriptions. That is, **do not** restrict `subscribeFilter`s to `${namespace}`!

For SAP Event Broker:

```json
"cds": {
"requires": {
"messaging": {
"kind": "event-broker"
}
}
}
```

With that, your developers can enter event names as they're found on SAP Business Accelerator Hub. And our CDS extensions, as previously described, simplify to that definition:

```cds
Expand All @@ -122,17 +137,19 @@ extend service S4 with {
```




## Configure SAP S/4HANA

As a prerequisite for consuming SAP S/4HANA events, the SAP S/4HANA system itself needs to be configured to send out specific event messages to a specific SAP Event Mesh service instance. How to create an SAP Event Mesh service instance and use it with a CAP application was already described in the previous sections. A description of how to configure an SAP S/4HANA system to send out specific events is out of scope of this documentation here. See [this documentation](https://help.sap.com/docs/BTP/65de2977205c403bbc107264b8eccf4b/d476ff058bf1413a9505c5c25cfce86b.html) for more details.
As a prerequisite for consuming SAP S/4HANA events, the SAP S/4HANA system itself needs to be configured to send out specific event messages to a specific SAP Event Mesh or SAP Event Broker service instance.
How to create the necessary service instances and use them with a CAP application was already described in the previous sections [SAP Event Mesh](./event-mesh) and [SAP Event Broker](./event-broker), respectively.
A description of how to configure an SAP S/4HANA system to send out specific events is out of scope of this documentation here.
See [this documentation](https://help.sap.com/docs/SAP_S4HANA_CLOUD/0f69f8fb28ac4bf48d2b57b9637e81fa/82e97d5329044732af1efd996bfdc2ab.html) for more details.


## Using Low-Level Messaging

Instead of adding events found on [SAP Business Accelerator Hub](https://api.sap.com/content-type/Events/events/packages) to a CDS service model, it's also possible to use a messaging service directly to consume events from SAP S/4HANA.

You have to bind the `messaging` service directly to the SAP Event Mesh service instance that the SAP S/4HANA system sends the event messages to. Then you can consume the event by registering a handler on the `type` of the event that should be received (`sap.s4.beh.businesspartner.v1.BusinessPartner.Changed.v1` in the example):
You have to bind the `messaging` service directly to the SAP Event Mesh or SAP Event Broker service instance that the SAP S/4HANA system sends the event messages to. Then you can consume the event by registering a handler on the `type` of the event that should be received (`sap.s4.beh.businesspartner.v1.BusinessPartner.Changed.v1` in the example):

```js
const messaging = await cds.connect.to ('messaging')
Expand Down
3 changes: 2 additions & 1 deletion menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@

- [Events & Messaging](guides/messaging/)

- [Events from S/4](guides/messaging/s4)
- [SAP Event Mesh](guides/messaging/event-mesh)
- [SAP Event Broker](guides/messaging/event-broker)
- [Events from S/4](guides/messaging/s4)

- [Protocols/APIs](advanced/publishing-apis/)

Expand Down
Loading