SampleSampletypeA worked example you read or clone. Evidence: it demonstrates, it never provides.See every one →What this type is →by SAPby SAPoriginPublished by SAP itself. A visible facet, never an input to a reading — a dormant official plugin reads exactly like a dormant independent one.See every one →Reference

SAP-samples/btp-event-driven-multi-tenant-architecture

A CAP reference sample showing SAP Event Mesh 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 Mesh 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 Cloud 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

Last pushLicenceApache-2.0

Where it sits

Lives in
Demonstrates
Event MeshCAPEvent MeshcapabilityEmitting and consuming business events across systems through brokers, including subscriptions and mapping application events to broker topics. Work that must survive a request, including deferred processing and retries, belongs to [async processing](capability:async-processing).MultitenancyCAPMultitenancycapabilityServing many tenants from one deployment — onboarding, tenant-isolated data, per-tenant schema deployment and the operational tooling around it. It is decided once, before anything is built, and narrows the artifacts in almost every capability downstream: most sharply in [caching](capability:caching) and anything else holding state in process.
Flavors

Who is behind it

SAP SamplesSAP SamplesOrganisationMaintains this
In the atlas: maintains 222
@SAP-samples
maintainerAlessandro BiagiPersonContributes to this
In the atlas: contributes to 4, wrote 2
@ale-biagi
1 contributor

What it declares

Every artifact

Type
Sample
Origin
By SAP
Use as
A reference

As a sample

Form
A reference application

Connections2

SAP-samples/btp-event-driven-multi-tenant-architecture connectionsSAP-samples/btp-event-driven-multi-tenant-architecturePROVIDES→ demonstrates2demonstrates authoredEvent Meshdemonstrates authoredMultitenancy

ArchitectureBetaRead from the sample's deployment descriptor. Some of the connections it states are not drawn yet.

as 2 deployment descriptors state it at fc6b0e9, read
event-consumer-mtxevent-consumer-mtx/mta.yaml
SAP BTP, Cloud Foundry Runtimeevent-consumer-mtxmta.yaml, module event-consumer-mtx-srv, requires event-consumer-mtx-authbinding, HTTP, outboundmta.yaml, module event-consumer-mtx-srv, requires app-apiapp-apimta.yaml, module event-consumer-mtx-app, requires event-consumer-mtx-authbindingOAuth 2.0, outboundmta.yaml, module event-consumer-mtx-app, requires srv-api; mta.yaml, module event-consumer-mtx-app, requires mtx-apisrv-api, mtx-apidocumentedoutboundSAP Authorization and Trust Management service, xsuaa, applicationSAP Authorizationand TrustManagement serviceSAP Destination service, destination, liteSAP Destinationserviceevent-consumer-mtx-srv, nodejsevent-consumer-mtx-s…event-consumer-mtx-app, approuter.nodejsevent-consumer-mtx-a…SAP Software-as-a-Service Provisioning service, saas-registry, applicationSAPSoftware-as-a-ServiceProvisioningserviceSAP Service Manager, service-manager, containerSAP ServiceManager
SAPnot SAP's, or the project's ownauthenticationstated in the documentdocumented only

Bound, and not drawn

Documented, with no instance in the document

SAP BTP, Cloud Foundry Runtimeevent-dispatchermta.yaml, module event-dispatcher-srv, requires event-dispatcher-authbinding, HTTP, outboundSAP Authorization and Trust Management service, xsuaa, applicationSAP Authorizationand TrustManagement serviceevent-dispatcher-srv, nodejsevent-dispatcher-srvevent-dispatcher-db-deployer, hdbevent-dispatcher-db-…Event Mesh, enterprise-messaging, defaultEvent Meshhana, hana, hdi-sharedhanaSAP Destination service, destination, liteSAP Destinationservice
SAPnot SAP's, or the project's ownauthenticationstated in the document

Bound, and not drawn

Documented, with no instance in the document

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, read
SAP-samples/btp-event-driven-multi-tenant-architecture/README.mdOn GitHub

SAP BTP Event-Driven Multi-Tenant Architecture with CAP and SAP Event Mesh

License: Apache2 REUSE status

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

Event-Driven Multi-Tenant 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
  1. Access your SAP Business Application Studio full-stack cloud development Dev Space
  2. Open a new terminal (if not yet opened): Terminal > New Terminal
  3. 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 projects before executing the command below.

mkdir event-driven-mtx
  1. 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
  1. Login to Cloud Foundry in the provider subaccount:
cd event-driven-mtx/event-consumer-mtx && cf login
  1. Build the MTA Archive:
mbt build
  1. Deploy the MTA Archive:
cf deploy mta_archives/event-consumer-mtx_1.0.0.mtar
Configure the CF API Destination
  1. In the SAP BTP Cockpit, on the left-hand pane click on Instances and Subscriptions
  2. In the Instances list locate the event-consumer-mtx-destination-service service instance and click on it
  3. In the new tab that will pop-up, on the left-hand pane, click on Destinations
  4. Locate the event-consumer-mtx-cfapi destination and click on Edit (small pencil on the right)
  5. In the Token Service URL change the word "login" to "uaa"
  6. 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.
  7. To enable the Save button write a single letter (e.g. "a") in the Client Secret
  8. Click on Save
  9. Click on Edit
  10. Clear the Client Secret
  11. Click on Save
Create the Destination to the Multi-Tenant Event Consumer application
  1. 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
  2. Make a copy of the URL under Application Routes
  3. On the left-hand pane click on Service Bindings
  4. Select the event-consumer-mtx-auth service instance
  5. Click on Show sensitive data
  6. Make a copy of clientid, clientsecret and url
  7. Back to the subaccount home page, on the left-hand pane expand Connectivity and click on Destinations
  8. Click on Create Destination
  9. 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).

  1. Click on Save
Deploy the Event Dispatcher service
  1. Back to the Business Application Studio terminal, build the MTA Archive:
cd ../event-dispatcher && mbt build
  1. Deploy the MTA Archive:
cf deploy mta_archives/event-dispatcher_1.0.0.mtar
Create the Destination to the Event Dispatcher service
  1. 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
  2. Make a copy of the URL under Application Routes
  3. On the left-hand pane click on Service Bindings
  4. Select the event-dispatcher-auth service instance
  5. Click on Show sensitive data
  6. Make a copy of clientid, clientsecret and url
  7. Back to the subaccount home page, on the left-hand pane expand Connectivity and click on Destinations
  8. Click on Create Destination
  9. 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.
  1. 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

  1. Create a subaccount in the same region as the provider subaccount where you deployed the solution
  2. Access the new subaccount and create a subscription of the Event Messages Consumer (Business Partners) application
  3. When the subscription process is completed click on Go to Application
  4. In your S/4HANA Cloud tenant (configured in the prerequisites) create or change a Business Partner (use the Manage Business Partner Master Data app)
  5. 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
  6. 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.

Apache-2.0, read

Details

Sources3
Added by handdiscovered herechecked
github.com/SAP-samples/btp-event-driven-multi-tenant-architecturetree, pushes, contributors, CIchecked
README.mdquoted, and what the entry declareschecked

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
discovered viaAdded by hand
first seen in the atlas
ecosystem and domaincap, integration-and-messaging
Flavors1
Node.js
“The code is developed using the **SAP Cloud Application Programming Model (CAP) NodeJS framework**” — SAP-samples/btp-event-driven-multi-tenant-architecture — READMEchecked
Contributors1

From the repository’s contributor list, .

History in the atlas1
  1. 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