SAP-samples/btp-event-driven-multi-tenant-architecture
A CAP reference sample showing SAP Event MeshEvent MeshManaged queues and topics over AMQP, MQTT and a REST gateway, and the bus SAP's own applications publish their business events to.sap official, btp brokering business-partner events from S/4HANA Cloud into a multi-tenant SaaS consumer application.
Two CAP Node.js microservices split the event flow: one consumes SAP Event MeshEvent MeshManaged queues and topics over AMQP, MQTT and a REST gateway, and the bus SAP's own applications publish their business events to.sap official, btp messages published by an S/4HANA Cloud business-partner topic, the other receives them as a multi-tenant application, routing each message to its subscriber by source. Provisioning runs through SAP Business Application Studio, an SAP HANA CloudSAP HANA CloudThe managed database under most of this: CAP's default target, the store Datasphere and Analytics Cloud sit on, and a service with plans and components.sap official, btp instance and an SAP Event Mesh instance in a provider subaccount, plus a destination per consumer subaccount, so a new S/4HANA Cloud tenant publishing to the same message client picks up its own subscription without touching the others. The README calls it a reference for experienced CAP developers, provided as is.
Facts
Where it sits
Who is behind it
In the atlas: maintains 222@SAP-samplesmaintainerAlessandro BiagiContributes to this
In the atlas: contributes to 4, wrote 2@ale-biagi1 contributor
What it declares
Every artifact
- Type
- Sample
- Origin
- By SAP
- Use as
- A reference
As a sample
- Form
- A reference application
Connections
Emitting and consuming business events across systems through brokers
Serving many tenants from one deployment
Download
Architecture
as 2 deployment descriptors state it at fc6b0e9, readDownload
Bound, and not drawn
- event-consumer-mtx-srvSAP Destination service, SAP Software-as-a-Service Provisioning service, SAP Service Manager
Documented, with no instance in the document
- @sap-cloud-sdk/connectivity requires SAP Connectivity serviceevent-consumer-mtx-srv
- @sap/xssec requires Cloud Identity Servicesevent-consumer-mtx-srv
- @sap/approuter requires Cloud Identity Servicesevent-consumer-mtx-appAuthenticating the user against Identity Authentication instead of, or alongside, SAP Authorization and Trust Management service. Bound to both, the router picks IAS.@sap/approuter 23.0.0 — README, authenticationType
Bound to both services: prefers ias if both authentication services can be used in the current subaccount, determined via BTP security endpoint (may impact response time)
- @sap/approuter requires SAP Connectivity serviceevent-consumer-mtx-appForwarding to an on-premise backend: the binding is required once a destination sets its ProxyType to on-premise.@sap/approuter 23.0.0 — README, destination ProxyType
if ProxyType set to `on-premise`, binding to SAP Cloud Platform connectivity service is required.
- @sap/approuter requires SAP HTML5 Application Repository service for SAP BTPevent-consumer-mtx-appServing static content from the repository rather than from the router's own folder. Bound, both the files and the xs-app.json routes come from there.@sap/approuter 23.0.0 — README, Integration with HTML5 Application Repository
When the application router interacts with HTML5 Application Repository to serve HTML5 Applications, all static content and routes (xs-app.json) are retrieved from HTML5 Application Repository.
Download
Bound, and not drawn
- event-dispatcher-srvEvent Mesh, hana, SAP Destination service
- event-dispatcher-db-deployerhana
Documented, with no instance in the document
- @sap-cloud-sdk/connectivity requires SAP Connectivity serviceevent-dispatcher-srv
- @sap/xssec requires Cloud Identity Servicesevent-dispatcher-srv
Bound in the descriptor, not joined to an entry
hana
README
quoted from SAP-samples/btp-event-driven-multi-tenant-architecture under Apache-2.0, readSAP BTP Event-Driven Multi-Tenant Architecture with CAP and SAP Event Mesh
Description
This sample code aims to help SAP developers (customers or partners) to develop event-driven applications on SAP Business Technology Platform using SAP Event Mesh as the event message broker with a SaaS Multi-Tenant approach. The code is developed using the SAP Cloud Application Programming Model (CAP) NodeJS framework leveraging its out-of-the-box messaging capabilities and implements two microservices: the first consumes event messages from a message queue in an SAP Event Mesh message client and dispatches them to the second, which is a multi-tenant application that receives such messages in the subscriber according to the message source.
IMPORTANT NOTE: please be aware that the code in this repository is targeted to experienced CAP developers and is provided as is, serving exclusively as a reference for further developments.
Solution Architecture

Requirements
- One SAP Business Technology Platform subaccount (cannot be trial as there's no SAP Event Mesh with plan "default" on such landscape) with Cloud Foundry environment enabled - this is the provider subaccount
- One or more SAP Business Technology Platform subaccounts (no Cloud Foundry enablement required) - these are the consumer/subscriber subaccounts
- SAP Business Application Studio entitlement / subscription (Full Stack Cloud Application Dev Space in the provider subaccount)
- SAP HANA Cloud entitlement (any subaccount)
- SAP Event Mesh with plan "default" entitlement in the provider subaccount
- SAP Event Mesh with plan "standard (Application)" entitlement in the provider subaccount
Prerequisites
- Subscribe to SAP Business Application Studio in the provider subaccount and create a Full Stack Cloud Application Dev Space
- Create a SAP HANA Cloud database instance with plan "hana-cloud" or share an existing one with the provider subaccount
- Subscribe to SAP Event Mesh "standard (Application)" plan in the provider subaccount
- Assign the following role collections to your user: Enterprise Messaging Administrator, Enterprise Messaging Developer, Enterprise Messaging Display, Enterprise Messaging Subscription Administrator
- Create a service instance of SAP Event Mesh "default" plan in the provider subaccount named s4-client1 using the parameters from the event-dispatcher/message-client-params.json file provided in this repo
- Create a service key named s4-client1-key for that service instance
- Using the SAP Event Mesh application subscription, access the s4-client01 message client and create a queue (with default parameters) named s4-client01-queue
- Subscribe that queue to the following topics: s4/msg/client01/ce/sap/s4/beh/businesspartner/v1/BusinessPartner/Created/v1 and s4/msg/client01/ce/sap/s4/beh/businesspartner/v1/BusinessPartner/Changed/v1
- Configure one or more S4/HANA Cloud tenants to publish the above topics to the s4-client01 message client (use the s4-client1-key you created for the service instance). To perform that setup follow the instructions from these two links: Creating Communication Arrangements and Maintain Outbound Event Topics
Download and Installation
Clone the Project Repo
- Access your SAP Business Application Studio full-stack cloud development Dev Space
- Open a new terminal (if not yet opened): Terminal > New Terminal
- From the default projects folder, create the project directory:
NOTE: if you have not set the projects folder to become your current workspace in BAS your terminal might end-up in the user folder. So, do
cd projectsbefore executing the command below.
mkdir event-driven-mtx
- Clone this main branch into the recently created directory:
git clone https://github.com/SAP-samples/btp-event-driven-multi-tenant-architecture.git event-driven-mtx
Deploy the Multi-Tenant Event Consumer application
- Login to Cloud Foundry in the provider subaccount:
cd event-driven-mtx/event-consumer-mtx && cf login
- Build the MTA Archive:
mbt build
- Deploy the MTA Archive:
cf deploy mta_archives/event-consumer-mtx_1.0.0.mtar
Configure the CF API Destination
- In the SAP BTP Cockpit, on the left-hand pane click on Instances and Subscriptions
- In the Instances list locate the event-consumer-mtx-destination-service service instance and click on it
- In the new tab that will pop-up, on the left-hand pane, click on Destinations
- Locate the event-consumer-mtx-cfapi destination and click on Edit (small pencil on the right)
- In the Token Service URL change the word "login" to "uaa"
- Provide a valid BTP user and password (user must be assigned to the subaccount CF org and space as org user and space developer respectively). IMPORTANT: do not take a user from a REAL person for this setup to avoid security issues, instead create a technical user following these specifications.
- To enable the Save button write a single letter (e.g. "a") in the Client Secret
- Click on Save
- Click on Edit
- Clear the Client Secret
- Click on Save
Create the Destination to the Multi-Tenant Event Consumer application
- In the SAP BTP Cockpit go to the Cloud Foundry space where you deployed the Multi-Tenant Event Consumer app, locate it in the apps list (event-consumer-mtx-app) and click on it
- Make a copy of the URL under Application Routes
- On the left-hand pane click on Service Bindings
- Select the event-consumer-mtx-auth service instance
- Click on Show sensitive data
- Make a copy of clientid, clientsecret and url
- Back to the subaccount home page, on the left-hand pane expand Connectivity and click on Destinations
- Click on Create Destination
- Fill the form with the following information:
- Name: Event-Consumer
- Type: HTTP
- Description: Consumer Tenant of Provider Event Messages
- URL: use the URL copied from the app Application Routes
- Authentication: OAuth2ClientCredentials
- Client ID: use the clientid copied from the service binding
- Client Secret: use the clientsecret copied from the service binding
- Token Service URL: replace the first part of the url copied from the service binding (text right after "https://" until the first "." - e.g. 'https://thispart.') with the word subDomain and append the path "/oauth/token" to that url. You will end-up with something like this: https://subDomain.authentication..hana.ondemand.com/oauth/token.
NOTE: it's extremely important that the word subDomain respects the case determined in this document ("sub" in lower-case, capital "D" and "omain" in lower-case).
- Click on Save
Deploy the Event Dispatcher service
- Back to the Business Application Studio terminal, build the MTA Archive:
cd ../event-dispatcher && mbt build
- Deploy the MTA Archive:
cf deploy mta_archives/event-dispatcher_1.0.0.mtar
Create the Destination to the Event Dispatcher service
- In the SAP BTP Cockpit go to the Cloud Foundry space where you deployed the Event Dispatcher service, locate it in the apps list (event-dispatcher-srv) and click on it
- Make a copy of the URL under Application Routes
- On the left-hand pane click on Service Bindings
- Select the event-dispatcher-auth service instance
- Click on Show sensitive data
- Make a copy of clientid, clientsecret and url
- Back to the subaccount home page, on the left-hand pane expand Connectivity and click on Destinations
- Click on Create Destination
- Fill the form with the following information:
- Name: Event-Dispatcher
- Type: HTTP
- Description: Multi-Tenant Event Dispatcher
- URL: use the URL copied from the app Application Routes
- Authentication: OAuth2ClientCredentials
- Client ID: use the clientid copied from the service binding
- Client Secret: use the clientsecret copied from the service binding
- Token Service URL: use the url copied from the service binding appending the path "/oauth/token" to it.
- Click on Save
Test the Solution
NOTE: before testing the solution make sure you have set up at least one S/4HANA Cloud tenant to publish CREATE and CHANGE topics from the Business Partner BO to the message client as described in the prerequisites
- Create a subaccount in the same region as the provider subaccount where you deployed the solution
- Access the new subaccount and create a subscription of the Event Messages Consumer (Business Partners) application
- When the subscription process is completed click on Go to Application
- In your S/4HANA Cloud tenant (configured in the prerequisites) create or change a Business Partner (use the Manage Business Partner Master Data app)
- Go back to the application on BTP and click "Go" to refresh the list report. You should now see the Business Partner Code that has been created or changed in your S/4HANA Cloud tenant along with the event timestamp
- You can now setup another S/4HANA Cloud tenant to publish the same topics to the same message client on BTP and repeat steps 1 to 5. Thus, for each new S/4HANA Cloud tenant publishing those topics to that same message client a new application subscription will capture the messages coming from such tenant and so on...
Code Details
You can find a detailed explanation about the mechanics and concepts of this project in this blog post.
Known Issues
No known issues.
How to obtain support
Create an issue in this repository if you find a bug or have questions about the content.
For additional support, ask a question in SAP Community.
Contributing
If you wish to contribute code, offer fixes or improvements, please send a pull request. Due to legal reasons, contributors will be asked to accept a DCO when they create the first pull request to this project. This happens in an automated fashion during the submission process. SAP uses the standard DCO text of the Linux Foundation.
License
Copyright (c) 2026 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the LICENSE file.
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
Flavors
“The code is developed using the **SAP Cloud Application Programming Model (CAP) NodeJS framework**” — SAP-samples/btp-event-driven-multi-tenant-architecture — README
Contributors
History in the atlas
- First seen.
For your agent
- Ref
artifact:sap-samples-btp-event-driven-multi-tenant-architecture- JSON
- /artifacts/sap-samples-btp-event-driven-multi-tenant-architecture.json
- MCP
- Connecting an agent