From 43934b7ed5147c25072458668fb190f5fb5071fe Mon Sep 17 00:00:00 2001 From: Vladislav Leonkev Date: Wed, 24 Sep 2025 11:27:59 +0200 Subject: [PATCH 01/18] shared-db w/ java --- guides/deployment/microservices.md | 270 ++++++++++++++++++++++++++++- 1 file changed, 266 insertions(+), 4 deletions(-) diff --git a/guides/deployment/microservices.md b/guides/deployment/microservices.md index 0f72155024..7560a2456f 100644 --- a/guides/deployment/microservices.md +++ b/guides/deployment/microservices.md @@ -35,6 +35,8 @@ This guide describes a way to manage development and deployment via *[monorepos] echo "{\"name\":\"@capire/samples\",\"workspaces\":[\"*\"]}" > package.json ``` +
+ 2. Add the previously mentioned projects as `git` submodules: ```sh @@ -48,6 +50,25 @@ This guide describes a way to manage development and deployment via *[monorepos] git submodule update --init ``` +
+ +
+ +2. Add the previously mentioned projects as `git` submodules: + + ```sh + git init + git submodule add https://github.com/capire/bookstore-java + git submodule add https://github.com/capire/reviews-java + git submodule add https://github.com/capire/orders-java + git submodule add https://github.com/capire/common-java + git submodule add https://github.com/capire/bookshop-java + git submodule add https://github.com/capire/data-viewer-java + git submodule update --init + ``` + +
+ Add a _.gitignore_ file with the following content: ```txt node_modules @@ -55,6 +76,9 @@ This guide describes a way to manage development and deployment via *[monorepos] ``` > The outcome of this looks and behaves exactly as the monorepo layout in *[cap/samples](https://github.com/capire/samples)*, so we can exercise the subsequent steps in there... + +
+ 3. Test-drive locally: ```sh npm install @@ -64,13 +88,24 @@ This guide describes a way to manage development and deployment via *[monorepos] cds w bookshop ``` + Each microservice can be started independently. If you start each microservice, one after the other in a different terminal, the connection is already established. + + [Learn more about Automatic Bindings by `cds watch`](../extensibility/composition#bindings-via-cds-watch){.learn-more} + +
+ +
+ +3. Test-drive locally: ```sh - cds w bookstore + npm install ``` - Each microservice can be started independently. If you start each microservice, one after the other in a different terminal, the connection is already established. + ```sh + cd bookstore && npm start + ``` - [Learn more about Automatic Bindings by `cds watch`](../extensibility/composition#bindings-via-cds-watch){.learn-more} +
::: details The project structure @@ -208,8 +243,18 @@ This section is about how to deploy all 3+1 projects at once with a common _mta. ![component diagram with synchronous and event communication for orders](./assets/microservices/bookstore.excalidraw.svg) +
+ [@capire/samples](https://github.com/capire/samples#readme) already has an all-in-one deployment implemented. Similar steps are necessary to convert projects with multiple CAP applications into a shared database deployment. +
+ +
+ +TODO [@capire/samples-java](https://github.com/capire/samples-java#readme) already has an all-in-one deployment implemented. Similar steps are necessary to convert projects with multiple CAP applications into a shared database deployment. + +
+ ### Deployment Descriptor Add initial multitarget application configuration for deployment to Cloud Foundry: @@ -258,6 +303,7 @@ build-parameters: ``` ::: +
::: info `cds build --ws` If the CDS models of every NPM workspace contained in the monorepo should be considered, then instead of creating this `shared-db` folder, you can also use: @@ -269,8 +315,12 @@ The `--ws` aggregates all models in the NPM workspaces. In this walkthrough, we only include a subset of the CDS models in the deployment. ::: +
+ +
::: details Configure each app for cloud readiness + The preceding steps only added configuration to the workspace root. Additionally add database configuration to each module that we want to deploy - bookstore, orders, and reviews: @@ -280,11 +330,25 @@ npm i @cap-js/hana --workspace bookstore npm i @cap-js/hana --workspace orders npm i @cap-js/hana --workspace reviews ``` + +::: + +
+ +
+ +::: details Configure each app for cloud readiness + +For each project add the **cds-starter-cloudfoundry** [starter bundle](https://cap.cloud.sap/docs/java/developing-applications/building#starter-bundles). + ::: +
### Applications +
+ Replace the MTA module for `samples-srv` with versions for each CAP service and adjust `name`, `path`, and `provides[0].name` to match the module name. Also change the `npm-ci` builder to the `npm` builder. ::: code-group @@ -347,7 +411,90 @@ modules: ``` ::: -Add build commands for each module to be deployed: +
+ +
+ +Replace the MTA module for `samples-srv` with versions for each CAP service and adjust `name`, `path`, and `provides[0].name` to match the module name. Also change the `npm-ci` builder to the `npm` builder. + +::: code-group +```yaml [mta.yaml] +modules: + + - name: bookstore-srv # [!code focus] + type: java + path: bookstore/srv # [!code focus] + parameters: + instances: 1 + buildpack: sap_java_buildpack_jakarta + properties: + SPRING_PROFILES_ACTIVE: cloud,sandbox + JBP_CONFIG_COMPONENTS: "jres: ['com.sap.xs.java.buildpack.jre.SAPMachineJRE']" + JBP_CONFIG_SAP_MACHINE_JRE: '{ version: 21.+ }' + build-parameters: + builder: custom + commands: + - mvn clean package -DskipTests=true --batch-mode + provides: # [!code focus] + - name: bookstore-api # [!code focus] + properties: + srv-url: ${default-url} + requires: + - name: samples-db + - name: samples-auth + - name: samples-messaging + - name: samples-destination + + - name: orders-srv # [!code focus] + type: java + path: orders/srv # [!code focus] + parameters: + instances: 1 + buildpack: sap_java_buildpack_jakarta + build-parameters: + builder: custom + commands: + - mvn clean package -DskipTests=true --batch-mode + build-result: target/*-exec.jar + provides: # [!code focus] + - name: orders-api # [!code focus] + properties: + srv-url: ${default-url} + requires: + - name: samples-db + - name: samples-auth + - name: samples-messaging + - name: samples-destination + + - name: reviews-srv # [!code focus] + type: java + path: reviews/srv # [!code focus] + parameters: + instances: 1 + buildpack: sap_java_buildpack_jakarta + build-parameters: + builder: custom + commands: + - mvn clean package -DskipTests=true --batch-mode + build-result: target/*-exec.jar + provides: # [!code focus] + - name: reviews-api # [!code focus] + properties: + srv-url: ${default-url} + requires: + - name: samples-db + - name: samples-auth + - name: samples-messaging + - name: samples-destination +... +``` +::: + +
+ +
+ +Add build commands for each module to be prepared for deployment: ::: code-group ```yaml [mta.yaml] @@ -367,6 +514,8 @@ build-parameters: Note that we use the *--ws-pack* option for some modules. It's important for node modules referencing other repository-local node modules. ::: +
+ ### Authentication @@ -400,6 +549,8 @@ Add the admin role ``` ::: +
+ ::: details Configure each app for cloud readiness Add NPM dependency `@sap/xssec`: @@ -410,10 +561,14 @@ npm i @sap/xssec --workspace reviews ``` ::: +
+ ### Messaging The messaging service is used to organize asynchronous communication between the CAP services. +
+ ```shell cds add enterprise-messaging ``` @@ -499,6 +654,69 @@ Enable messaging for the modules that use it: ::: +
+ +
+ +Create a new file named event-mesh.json to store the configuration for enterprise messaging. Skip the *emname* and *namespace* properties, as these will be parameterized dynamically in the mta.yaml file: + +::: code-group +```json [event-mesh.json] +{ + "version": "1.1.0", + "emname": "samples-emname", // [!code --] + "version": "1.1.0", + "namespace": "default/samples/1", // [!code --] + "options": { + "management": true, + "messagingrest": true, + "messaging": true + }, + "rules": { + "topicRules": { + "publishFilter": [ + "*" + ], + "subscribeFilter": [ + "*" + ] + }, + "queueRules": { + "publishFilter": [ + "*" + ], + "subscribeFilter": [ + "*" + ] + } + }, + "authorities": [ + "$ACCEPT_GRANTED_AUTHORITIES" + ] +} +``` +::: + +Add messaging resource in mta.yaml with parametrized *emname* and *namespace* properties: + +::: code-group +```yaml [mta.yaml] +resources: + - name: samples-messaging + type: org.cloudfoundry.managed-service + parameters: + service: enterprise-messaging + service-plan: default + path: ./event-mesh.json + config: # [!code ++] + emname: bookstore-${org}-${space} # [!code ++] + namespace: cap/samples/${space} # [!code ++] +``` +::: + + +
+ ### Destinations @@ -550,6 +768,8 @@ modules: Use the destinations in the bookstore application: +
+ ::: code-group ```yaml [mta.yaml] modules: @@ -561,6 +781,35 @@ modules: ``` ::: +
+ +
+ +::: code-group +```yaml [bookstore/srv/src/main/resources/application.yaml] +cds: + odataV4.endpoint.path: / + messaging.services: + samples-messaging: + kind: enterprise-messaging + remote.services: # [!code ++] + OrdersService: # [!code ++] + type: "odata-v4" # [!code ++] + http: # [!code ++] + suffix: "/odata/v4" # [!code ++] + destination: # [!code ++] + name: "orders-dest" # [!code ++] + ReviewsService: # [!code ++] + type: "odata-v4" # [!code ++] + destination: # [!code ++] + name: "reviews-dest" # [!code ++] +``` +::: + +
+ +
+ ::: details Configure each app for cloud readiness Add `@sap-cloud-sdk/http-client` and `@sap-cloud-sdk/resilience` for each module utilizing the destinations: @@ -571,6 +820,19 @@ npm i @sap-cloud-sdk/resilience --workspace bookstore ``` ::: +
+ + +
+ +::: details Configure each app for cloud readiness + +Add dependency to the **cds-feature-remote-odata** [application plugin](https://cap.cloud.sap/docs/java/developing-applications/building#standard-modules) + +::: + +
+ ### Approuter Add [approuter configuration](../deployment/to-cf#add-app-router) using the command: From c448fdac5822444e20c2c74b4f5df98188d86d0c Mon Sep 17 00:00:00 2001 From: Vladislav Leonkev Date: Wed, 8 Oct 2025 15:49:03 +0200 Subject: [PATCH 02/18] update --- guides/deployment/microservices.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/guides/deployment/microservices.md b/guides/deployment/microservices.md index 7560a2456f..4707e6a969 100644 --- a/guides/deployment/microservices.md +++ b/guides/deployment/microservices.md @@ -658,7 +658,7 @@ Enable messaging for the modules that use it:
-Create a new file named event-mesh.json to store the configuration for enterprise messaging. Skip the *emname* and *namespace* properties, as these will be parameterized dynamically in the mta.yaml file: +Create a new file named event-mesh.json to store the configuration for enterprise messaging. Skip the `emname` and `namespace` properties, as these will be parameterized dynamically in the mta.yaml file: ::: code-group ```json [event-mesh.json] @@ -697,7 +697,7 @@ Create a new file named event-mesh.json to store the configuration for enterpris ``` ::: -Add messaging resource in mta.yaml with parametrized *emname* and *namespace* properties: +Add messaging resource in mta.yaml with parametrized `emname` and `namespace` properties: ::: code-group ```yaml [mta.yaml] From 13f868e96818970a94631c4155627f6b54e0808c Mon Sep 17 00:00:00 2001 From: Rene Jeglinsky Date: Fri, 10 Oct 2025 12:43:54 +0200 Subject: [PATCH 03/18] remove toggles, initial version --- guides/deployment/microservices.md | 155 +++++++---------------------- 1 file changed, 37 insertions(+), 118 deletions(-) diff --git a/guides/deployment/microservices.md b/guides/deployment/microservices.md index 4707e6a969..aee6f1b679 100644 --- a/guides/deployment/microservices.md +++ b/guides/deployment/microservices.md @@ -35,11 +35,10 @@ This guide describes a way to manage development and deployment via *[monorepos] echo "{\"name\":\"@capire/samples\",\"workspaces\":[\"*\"]}" > package.json ``` -
- 2. Add the previously mentioned projects as `git` submodules: - ```sh + ::: code-group + ```sh [Node.js] git init git submodule add https://github.com/capire/bookstore git submodule add https://github.com/capire/reviews @@ -49,14 +48,7 @@ This guide describes a way to manage development and deployment via *[monorepos] git submodule add https://github.com/capire/data-viewer git submodule update --init ``` - -
- -
- -2. Add the previously mentioned projects as `git` submodules: - - ```sh + ```sh [Java] git init git submodule add https://github.com/capire/bookstore-java git submodule add https://github.com/capire/reviews-java @@ -66,8 +58,7 @@ This guide describes a way to manage development and deployment via *[monorepos] git submodule add https://github.com/capire/data-viewer-java git submodule update --init ``` - -
+ ::: Add a _.gitignore_ file with the following content: ```txt @@ -77,42 +68,30 @@ This guide describes a way to manage development and deployment via *[monorepos] > The outcome of this looks and behaves exactly as the monorepo layout in *[cap/samples](https://github.com/capire/samples)*, so we can exercise the subsequent steps in there... -
- 3. Test-drive locally: - ```sh + + ::: code-group + ```sh [Node.js] npm install - ``` - - ```sh cds w bookshop ``` - - Each microservice can be started independently. If you start each microservice, one after the other in a different terminal, the connection is already established. - - [Learn more about Automatic Bindings by `cds watch`](../extensibility/composition#bindings-via-cds-watch){.learn-more} - -
- -
- -3. Test-drive locally: - ```sh + ```sh [Java] npm install - ``` - - ```sh cd bookstore && npm start ``` + ::: -
+ In Node.js, each microservice can be started independently. If you start each microservice, one after the other in a different terminal, the connection is already established. + + [Learn more about Automatic Bindings by `cds watch`](../extensibility/composition#bindings-via-cds-watch){.learn-more} ::: details The project structure The project structure used here is as follows: -```txt +::: code-group +```txt [Node.js] / ├─ bookstore/ ├─ orders/ @@ -120,6 +99,14 @@ The project structure used here is as follows: ├─ ... └─ package.json ``` +```txt [Java] +/ +├─ bookstore-java/ +├─ orders-java/ +├─ reviews-java/ +├─ ... +└─ package.json +``` The individual services (`bookstore`, `reviews`, `orders`) can be one of the following: * folders, committed directly to the root project @@ -243,17 +230,9 @@ This section is about how to deploy all 3+1 projects at once with a common _mta. ![component diagram with synchronous and event communication for orders](./assets/microservices/bookstore.excalidraw.svg) -
- -[@capire/samples](https://github.com/capire/samples#readme) already has an all-in-one deployment implemented. Similar steps are necessary to convert projects with multiple CAP applications into a shared database deployment. - -
+For Node.js, [@capire/samples](https://github.com/capire/samples#readme) already has an all-in-one deployment implemented. Similar steps are necessary to convert projects with multiple CAP applications into a shared database deployment. -
- -TODO [@capire/samples-java](https://github.com/capire/samples-java#readme) already has an all-in-one deployment implemented. Similar steps are necessary to convert projects with multiple CAP applications into a shared database deployment. - -
+TODO For CAP Java, [@capire/samples-java](https://github.com/capire/samples-java#readme) already has an all-in-one deployment implemented. Similar steps are necessary to convert projects with multiple CAP applications into a shared database deployment. ### Deployment Descriptor @@ -303,9 +282,7 @@ build-parameters: ``` ::: -
- -::: info `cds build --ws` +::: info `cds build --ws` with Node.js If the CDS models of every NPM workspace contained in the monorepo should be considered, then instead of creating this `shared-db` folder, you can also use: ```shell cds build --for hana --production --ws @@ -315,11 +292,7 @@ The `--ws` aggregates all models in the NPM workspaces. In this walkthrough, we only include a subset of the CDS models in the deployment. ::: -
- -
- -::: details Configure each app for cloud readiness +::: details Node.js: Configure each app for cloud readiness The preceding steps only added configuration to the workspace root. @@ -333,26 +306,18 @@ npm i @cap-js/hana --workspace reviews ::: -
- -
- -::: details Configure each app for cloud readiness +::: details CAP Java: Configure each app for cloud readiness For each project add the **cds-starter-cloudfoundry** [starter bundle](https://cap.cloud.sap/docs/java/developing-applications/building#starter-bundles). ::: -
- ### Applications -
- Replace the MTA module for `samples-srv` with versions for each CAP service and adjust `name`, `path`, and `provides[0].name` to match the module name. Also change the `npm-ci` builder to the `npm` builder. ::: code-group -```yaml [mta.yaml] +```yaml [Node.js (mta.yaml)] modules: - name: bookstore-srv # [!code focus] type: nodejs @@ -409,16 +374,7 @@ modules: - name: samples-destination ... ``` -::: - -
- -
- -Replace the MTA module for `samples-srv` with versions for each CAP service and adjust `name`, `path`, and `provides[0].name` to match the module name. Also change the `npm-ci` builder to the `npm` builder. - -::: code-group -```yaml [mta.yaml] +```yaml [Java (mta.yaml)] modules: - name: bookstore-srv # [!code focus] @@ -490,11 +446,7 @@ modules: ``` ::: -
- -
- -Add build commands for each module to be prepared for deployment: +In Node.js, add build commands for each module to be prepared for deployment: ::: code-group ```yaml [mta.yaml] @@ -514,9 +466,6 @@ build-parameters: Note that we use the *--ws-pack* option for some modules. It's important for node modules referencing other repository-local node modules. ::: -
- - ### Authentication Add [security configuration](../security/authorization#xsuaa-configuration) using the command: @@ -549,9 +498,7 @@ Add the admin role ``` ::: -
- -::: details Configure each app for cloud readiness +::: details Node.js: Configure each app for cloud readiness Add NPM dependency `@sap/xssec`: ```shell @@ -561,13 +508,11 @@ npm i @sap/xssec --workspace reviews ``` ::: -
- ### Messaging The messaging service is used to organize asynchronous communication between the CAP services. -
+#### In Node.js ```shell cds add enterprise-messaging @@ -654,9 +599,7 @@ Enable messaging for the modules that use it: ::: -
- -
+#### In CAP Java Create a new file named event-mesh.json to store the configuration for enterprise messaging. Skip the `emname` and `namespace` properties, as these will be parameterized dynamically in the mta.yaml file: @@ -714,10 +657,6 @@ resources: ``` ::: - -
- - ### Destinations Add [destination configuration](https://cap.cloud.sap/docs/guides/using-services#using-destinations) for connectivity between the apps: @@ -768,10 +707,8 @@ modules: Use the destinations in the bookstore application: -
- ::: code-group -```yaml [mta.yaml] +```yaml [Node.js (mta.yaml)] modules: - name: bookstore-srv ... @@ -779,14 +716,7 @@ modules: cds_requires_ReviewsService_credentials: {"destination": "reviews-dest","path": "/reviews"} # [!code ++] cds_requires_OrdersService_credentials: {"destination": "orders-dest","path": "/odata/v4/orders"} # [!code ++] ``` -::: - -
- -
- -::: code-group -```yaml [bookstore/srv/src/main/resources/application.yaml] +```yaml [Java (bookstore/srv/src/main/resources/application.yaml)] cds: odataV4.endpoint.path: / messaging.services: @@ -806,11 +736,7 @@ cds: ``` ::: -
- -
- -::: details Configure each app for cloud readiness +::: details Node.js: Configure each app for cloud readiness Add `@sap-cloud-sdk/http-client` and `@sap-cloud-sdk/resilience` for each module utilizing the destinations: @@ -820,19 +746,12 @@ npm i @sap-cloud-sdk/resilience --workspace bookstore ``` ::: -
- - -
- -::: details Configure each app for cloud readiness +::: details CAP Java: Configure each app for cloud readiness Add dependency to the **cds-feature-remote-odata** [application plugin](https://cap.cloud.sap/docs/java/developing-applications/building#standard-modules) ::: -
- ### Approuter Add [approuter configuration](../deployment/to-cf#add-app-router) using the command: From 6f7637eb2d89511b61c304d18b9b21f5764db891 Mon Sep 17 00:00:00 2001 From: Vladislav Leonkev Date: Mon, 13 Oct 2025 11:20:35 +0200 Subject: [PATCH 04/18] improve remote odata with destinations --- guides/deployment/microservices.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/guides/deployment/microservices.md b/guides/deployment/microservices.md index aee6f1b679..31dfd7d9ce 100644 --- a/guides/deployment/microservices.md +++ b/guides/deployment/microservices.md @@ -748,8 +748,26 @@ npm i @sap-cloud-sdk/resilience --workspace bookstore ::: details CAP Java: Configure each app for cloud readiness -Add dependency to the **cds-feature-remote-odata** [application plugin](https://cap.cloud.sap/docs/java/developing-applications/building#standard-modules) +To access remote OData services, you need to add a dependency to the *cds-feature-remote-odata* [application plugin](https://cap.cloud.sap/docs/java/developing-applications/building#standard-modules) and provide the latest available version. Additionally, to retrieve destination configurations using the destination service, you must include a *com.sap.cloud.sdk.cloudplatform* dependency with artifact ID *scp-cf*, as described in the following steps: [Cloud SDK Integration](https://cap.cloud.sap/docs/java/cqn-services/remote-services#cloud-sdk-dependencies). +::: code-group +```xml [bookstore/srv/pom.xml] +... + +... + + com.sap.cds + cds-feature-remote-odata + runtime + 4.0.2 + + + + com.sap.cloud.sdk.cloudplatform + scp-cf + +... +``` ::: ### Approuter From a5a9f8843f3b4f801d1df9f9b7a45146bf115779 Mon Sep 17 00:00:00 2001 From: Vladislav Leonkev Date: Fri, 19 Dec 2025 14:45:16 +0100 Subject: [PATCH 05/18] reuse common, data-viewer --- guides/deployment/microservices.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/guides/deployment/microservices.md b/guides/deployment/microservices.md index 5c5d8a0d2a..11fce61b81 100644 --- a/guides/deployment/microservices.md +++ b/guides/deployment/microservices.md @@ -53,9 +53,9 @@ This guide describes a way to manage development and deployment via *[monorepos] git submodule add https://github.com/capire/bookstore-java git submodule add https://github.com/capire/reviews-java git submodule add https://github.com/capire/orders-java - git submodule add https://github.com/capire/common-java + git submodule add https://github.com/capire/common git submodule add https://github.com/capire/bookshop-java - git submodule add https://github.com/capire/data-viewer-java + git submodule add https://github.com/capire/data-viewer git submodule update --init ``` ::: @@ -67,7 +67,6 @@ This guide describes a way to manage development and deployment via *[monorepos] ``` > The outcome of this looks and behaves exactly as the monorepo layout in *[cap/samples](https://github.com/capire/samples)*, so we can exercise the subsequent steps in there... - 3. Test-drive locally: ::: code-group @@ -232,7 +231,7 @@ This section is about how to deploy all 3+1 projects at once with a common _mta. For Node.js, [@capire/samples](https://github.com/capire/samples#readme) already has an all-in-one deployment implemented. Similar steps are necessary to convert projects with multiple CAP applications into a shared database deployment. -TODO For CAP Java, [@capire/samples-java](https://github.com/capire/samples-java#readme) already has an all-in-one deployment implemented. Similar steps are necessary to convert projects with multiple CAP applications into a shared database deployment. +For CAP Java, [@capire/samples-java](https://github.com/capire/samples-java#readme) already has an all-in-one deployment implemented. Similar steps are necessary to convert projects with multiple CAP applications into a shared database deployment. ### Deployment Descriptor @@ -640,7 +639,7 @@ Create a new file named event-mesh.json to store the configuration for enterpris ``` ::: -Add messaging resource in mta.yaml with parametrized `emname` and `namespace` properties: +Add a messaging resource in mta.yaml with parameterized `emname` and `namespace` properties: ::: code-group ```yaml [mta.yaml] From 50b1880738dc435005d15a57f2fefe4243b222ae Mon Sep 17 00:00:00 2001 From: Vladislav Leonkev Date: Fri, 19 Dec 2025 14:53:16 +0100 Subject: [PATCH 06/18] small improvements --- guides/deployment/microservices.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/deployment/microservices.md b/guides/deployment/microservices.md index 11fce61b81..0670e74b47 100644 --- a/guides/deployment/microservices.md +++ b/guides/deployment/microservices.md @@ -607,7 +607,6 @@ Create a new file named event-mesh.json to store the configuration for enterpris { "version": "1.1.0", "emname": "samples-emname", // [!code --] - "version": "1.1.0", "namespace": "default/samples/1", // [!code --] "options": { "management": true, @@ -767,6 +766,7 @@ To access remote OData services, you need to add a dependency to the *cds-featur ... ``` + ::: ### App Router From 8df033ab62a5ccd46bda6f47cc217bfc59bf021e Mon Sep 17 00:00:00 2001 From: Vladislav Leonkev Date: Fri, 19 Dec 2025 14:56:30 +0100 Subject: [PATCH 07/18] improve --- guides/deployment/microservices.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/guides/deployment/microservices.md b/guides/deployment/microservices.md index 0670e74b47..14727128d3 100644 --- a/guides/deployment/microservices.md +++ b/guides/deployment/microservices.md @@ -66,7 +66,6 @@ This guide describes a way to manage development and deployment via *[monorepos] gen ``` > The outcome of this looks and behaves exactly as the monorepo layout in *[cap/samples](https://github.com/capire/samples)*, so we can exercise the subsequent steps in there... - 3. Test-drive locally: ::: code-group @@ -746,7 +745,7 @@ npm i @sap-cloud-sdk/resilience --workspace bookstore ::: details CAP Java: Configure each app for cloud readiness -To access remote OData services, you need to add a dependency to the *cds-feature-remote-odata* [application plugin](https://cap.cloud.sap/docs/java/developing-applications/building#standard-modules) and provide the latest available version. Additionally, to retrieve destination configurations using the destination service, you must include a *com.sap.cloud.sdk.cloudplatform* dependency with artifact ID *scp-cf*, as described in the following steps: [Cloud SDK Integration](https://cap.cloud.sap/docs/java/cqn-services/remote-services#cloud-sdk-dependencies). +To access remote OData services, add a dependency to the *cds-feature-remote-odata* [application plugin](https://cap.cloud.sap/docs/java/developing-applications/building#standard-modules) and provide the latest available version. Additionally, to retrieve destination configurations using the destination service, include a *com.sap.cloud.sdk.cloudplatform* dependency with artifact ID *scp-cf*, as described in the following steps: [Cloud SDK Integration](https://cap.cloud.sap/docs/java/cqn-services/remote-services#cloud-sdk-dependencies). ::: code-group ```xml [bookstore/srv/pom.xml] From a1efe3b62ff1002324dab56207ed0b3545807303 Mon Sep 17 00:00:00 2001 From: Vladislav Leonkev Date: Fri, 19 Dec 2025 14:59:44 +0100 Subject: [PATCH 08/18] improve --- guides/deployment/microservices.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/deployment/microservices.md b/guides/deployment/microservices.md index 14727128d3..40bf88a46a 100644 --- a/guides/deployment/microservices.md +++ b/guides/deployment/microservices.md @@ -745,7 +745,7 @@ npm i @sap-cloud-sdk/resilience --workspace bookstore ::: details CAP Java: Configure each app for cloud readiness -To access remote OData services, add a dependency to the *cds-feature-remote-odata* [application plugin](https://cap.cloud.sap/docs/java/developing-applications/building#standard-modules) and provide the latest available version. Additionally, to retrieve destination configurations using the destination service, include a *com.sap.cloud.sdk.cloudplatform* dependency with artifact ID *scp-cf*, as described in the following steps: [Cloud SDK Integration](https://cap.cloud.sap/docs/java/cqn-services/remote-services#cloud-sdk-dependencies). +To access remote OData services, add a dependency to the *cds-feature-remote-odata* [application plugin](https://cap.cloud.sap/docs/java/developing-applications/building#standard-modules) and provide the latest available version. Additionally, to retrieve destination configurations using the destination service, include a *com.sap.cloud.sdk.cloudplatform* dependency with artifact ID *scp-cf*, as described in [Cloud SDK Integration](https://cap.cloud.sap/docs/java/cqn-services/remote-services#cloud-sdk-dependencies). ::: code-group ```xml [bookstore/srv/pom.xml] From 65023b188fbf28276e429fe792ae06e239eca7b2 Mon Sep 17 00:00:00 2001 From: Vladislav Leonkev Date: Fri, 19 Dec 2025 15:01:30 +0100 Subject: [PATCH 09/18] improve --- guides/deployment/microservices.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/deployment/microservices.md b/guides/deployment/microservices.md index 40bf88a46a..019fc8cbc9 100644 --- a/guides/deployment/microservices.md +++ b/guides/deployment/microservices.md @@ -599,7 +599,7 @@ Enable messaging for the modules that use it: #### In CAP Java -Create a new file named event-mesh.json to store the configuration for enterprise messaging. Skip the `emname` and `namespace` properties, as these will be parameterized dynamically in the mta.yaml file: +Create a new file named event-mesh.json to store the configuration for enterprise messaging. Skip the `emname` and `namespace` properties, as the mta.yaml file parameterizes these dynamically: ::: code-group ```json [event-mesh.json] From 0b46dc2146fdd0e849f97f05ccebe74f31273246 Mon Sep 17 00:00:00 2001 From: Vladislav Leonkev Date: Fri, 19 Dec 2025 15:03:51 +0100 Subject: [PATCH 10/18] improve --- guides/deployment/microservices.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/deployment/microservices.md b/guides/deployment/microservices.md index 019fc8cbc9..5525d13048 100644 --- a/guides/deployment/microservices.md +++ b/guides/deployment/microservices.md @@ -745,7 +745,7 @@ npm i @sap-cloud-sdk/resilience --workspace bookstore ::: details CAP Java: Configure each app for cloud readiness -To access remote OData services, add a dependency to the *cds-feature-remote-odata* [application plugin](https://cap.cloud.sap/docs/java/developing-applications/building#standard-modules) and provide the latest available version. Additionally, to retrieve destination configurations using the destination service, include a *com.sap.cloud.sdk.cloudplatform* dependency with artifact ID *scp-cf*, as described in [Cloud SDK Integration](https://cap.cloud.sap/docs/java/cqn-services/remote-services#cloud-sdk-dependencies). +To access remote OData services, add a dependency to the *cds-feature-remote-odata* [application plugin](https://cap.cloud.sap/docs/java/developing-applications/building#standard-modules) and provide the latest available version. Additionally, to retrieve destination configurations using the destination service, include a *com.sap.cloud.sdk.cloudplatform* dependency with the *scp-cf* artifact ID, as described in [Cloud SDK Integration](https://cap.cloud.sap/docs/java/cqn-services/remote-services#cloud-sdk-dependencies). ::: code-group ```xml [bookstore/srv/pom.xml] From 7fed5b4c9f5d3d2e6ca4cd2a76dbf75c890d678d Mon Sep 17 00:00:00 2001 From: Vladislav Leonkev Date: Mon, 22 Dec 2025 11:25:45 +0100 Subject: [PATCH 11/18] change folder names --- guides/deployment/microservices.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/guides/deployment/microservices.md b/guides/deployment/microservices.md index 5525d13048..85b45dc95c 100644 --- a/guides/deployment/microservices.md +++ b/guides/deployment/microservices.md @@ -50,11 +50,11 @@ This guide describes a way to manage development and deployment via *[monorepos] ``` ```sh [Java] git init - git submodule add https://github.com/capire/bookstore-java - git submodule add https://github.com/capire/reviews-java - git submodule add https://github.com/capire/orders-java + git submodule add https://github.com/capire/bookstore-java bookstore + git submodule add https://github.com/capire/reviews-java reviews + git submodule add https://github.com/capire/orders-java orders git submodule add https://github.com/capire/common - git submodule add https://github.com/capire/bookshop-java + git submodule add https://github.com/capire/bookshop-java bookshop git submodule add https://github.com/capire/data-viewer git submodule update --init ``` @@ -67,7 +67,7 @@ This guide describes a way to manage development and deployment via *[monorepos] ``` > The outcome of this looks and behaves exactly as the monorepo layout in *[cap/samples](https://github.com/capire/samples)*, so we can exercise the subsequent steps in there... 3. Test-drive locally: - + ::: code-group ```sh [Node.js] npm install From de4a3a5831cc45d8fc145af7e050d11201a2c3c1 Mon Sep 17 00:00:00 2001 From: Vladislav Leonkev Date: Mon, 22 Dec 2025 11:51:19 +0100 Subject: [PATCH 12/18] improve --- guides/deployment/microservices.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/guides/deployment/microservices.md b/guides/deployment/microservices.md index 85b45dc95c..721f458691 100644 --- a/guides/deployment/microservices.md +++ b/guides/deployment/microservices.md @@ -150,22 +150,34 @@ These are the (not so beneficial) side effects you when using a shared persisten cds init shared-db --add hana ``` - ```sh + ::: code-group + ```sh [Node.js] npm add --workspace shared-db @capire/bookstore npm add --workspace shared-db @capire/reviews npm add --workspace shared-db @capire/orders ``` + ```sh [Java] + npm add --workspace shared-db @capire/bookstore-java + npm add --workspace shared-db @capire/reviews-java + npm add --workspace shared-db @capire/orders-java + ``` + ::: > Note how *NPM workspaces* allows us to use the package names of the projects, and nicely creates symlinks in *node_modules* accordingly. 2. Add a `shared-db/db/schema.cds` file as a mashup to actually collect the models: ::: code-group - ```cds [shared-db/db/schema.cds] + ```cds [Node-js] using from '@capire/bookstore'; using from '@capire/reviews'; using from '@capire/orders'; ``` + ```cds [Java] + using from '@capire/bookstore-java'; + using from '@capire/reviews-java'; + using from '@capire/orders-java'; + ``` ::: > Note: the `using` directives refer to `index.cds` files existing in the target packages. Your projects may have different entry points. From d6ac2414e7c3f50038e1c868ab6264e48b265b7d Mon Sep 17 00:00:00 2001 From: Vladislav Leonkev Date: Mon, 22 Dec 2025 11:55:08 +0100 Subject: [PATCH 13/18] typo --- guides/deployment/microservices.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/deployment/microservices.md b/guides/deployment/microservices.md index 721f458691..547f7dfa6a 100644 --- a/guides/deployment/microservices.md +++ b/guides/deployment/microservices.md @@ -168,7 +168,7 @@ These are the (not so beneficial) side effects you when using a shared persisten 2. Add a `shared-db/db/schema.cds` file as a mashup to actually collect the models: ::: code-group - ```cds [Node-js] + ```cds [Node.js] using from '@capire/bookstore'; using from '@capire/reviews'; using from '@capire/orders'; From 6d12d8af27169eecfe738287071805b2b67b884c Mon Sep 17 00:00:00 2001 From: Vladislav Leonkev Date: Mon, 22 Dec 2025 12:19:20 +0100 Subject: [PATCH 14/18] improve --- guides/deployment/microservices.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/deployment/microservices.md b/guides/deployment/microservices.md index 547f7dfa6a..12ba5e1d74 100644 --- a/guides/deployment/microservices.md +++ b/guides/deployment/microservices.md @@ -611,7 +611,7 @@ Enable messaging for the modules that use it: #### In CAP Java -Create a new file named event-mesh.json to store the configuration for enterprise messaging. Skip the `emname` and `namespace` properties, as the mta.yaml file parameterizes these dynamically: +Create a new file named event-mesh.json to store the configuration for enterprise messaging. Skip the `emname` and `namespace` properties because the mta.yaml file parameterizes these dynamically: ::: code-group ```json [event-mesh.json] From b4106ae543047a51ab455b24c130c2b7c8da6dc6 Mon Sep 17 00:00:00 2001 From: Vladislav Leonkev Date: Mon, 22 Dec 2025 17:20:27 +0100 Subject: [PATCH 15/18] add service name --- guides/deploy/microservices.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/guides/deploy/microservices.md b/guides/deploy/microservices.md index edf4529ec5..3cc893ce0c 100644 --- a/guides/deploy/microservices.md +++ b/guides/deploy/microservices.md @@ -733,12 +733,14 @@ cds: kind: enterprise-messaging remote.services: # [!code ++] OrdersService: # [!code ++] + name: sap.capire.orders.api.OrdersService # [!code ++] type: "odata-v4" # [!code ++] http: # [!code ++] suffix: "/odata/v4" # [!code ++] destination: # [!code ++] name: "orders-dest" # [!code ++] ReviewsService: # [!code ++] + name: sap.capire.reviews.api.ReviewsService # [!code ++] type: "odata-v4" # [!code ++] destination: # [!code ++] name: "reviews-dest" # [!code ++] From b30508501166d1da2194423091238f2c89e8d8ee Mon Sep 17 00:00:00 2001 From: Vladislav Leonkev Date: Mon, 29 Dec 2025 12:24:03 +0100 Subject: [PATCH 16/18] add missing line --- guides/deploy/microservices.md | 1 + 1 file changed, 1 insertion(+) diff --git a/guides/deploy/microservices.md b/guides/deploy/microservices.md index 3cc893ce0c..a828c3c14b 100644 --- a/guides/deploy/microservices.md +++ b/guides/deploy/microservices.md @@ -401,6 +401,7 @@ modules: builder: custom commands: - mvn clean package -DskipTests=true --batch-mode + build-result: target/*-exec.jar provides: # [!code focus] - name: bookstore-api # [!code focus] properties: From 5a2fa19eabe42e60c95203de8a267d6febf7ef75 Mon Sep 17 00:00:00 2001 From: Vladislav Leonkev Date: Mon, 29 Dec 2025 18:09:17 +0100 Subject: [PATCH 17/18] approuter config --- guides/deploy/microservices.md | 61 +++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 12 deletions(-) diff --git a/guides/deploy/microservices.md b/guides/deploy/microservices.md index a828c3c14b..6c1f2db1b7 100644 --- a/guides/deploy/microservices.md +++ b/guides/deploy/microservices.md @@ -869,10 +869,47 @@ modules: ``` ::: -The _xs-app.json_ file describes how to forward incoming request to the API endpoint / OData services and is located in the _.deploy/app-router_ folder. Each exposed CAP Service endpoint needs to be directed to the corresponding application which is providing this CAP service. +The _xs-app.json_ file describes how to forward incoming request to the API endpoint / OData services and is located in the _.deploy/app-router_ folder. Each exposed CAP Service endpoint needs to be directed to the corresponding application which is providing this CAP service. Modify the file _.deploy/app-router/xs-app.json_ as follows: ::: code-group -```json [.deploy/app-router/xs-app.json] +```json [Node.js] +{ + "routes": [ + { // [!code --] + "source": "^/(.*)$", // [!code --] + "target": "$1", // [!code --] + "destination": "srv-api", // [!code --] + "csrfProtection": true // [!code --] + } // [!code --] + { // [!code ++] + "source": "^/admin/", // [!code ++] + "destination": "bookstore-api", // [!code ++] + "csrfProtection": true // [!code ++] + }, // [!code ++] + { // [!code ++] + "source": "^/browse/", // [!code ++] + "destination": "bookstore-api", // [!code ++] + "csrfProtection": true // [!code ++] + }, // [!code ++] + { // [!code ++] + "source": "^/user/", // [!code ++] + "destination": "bookstore-api", // [!code ++] + "csrfProtection": true // [!code ++] + }, // [!code ++] + { // [!code ++] + "source": "^/odata/v4/orders/", // [!code ++] + "destination": "orders-api", // [!code ++] + "csrfProtection": true // [!code ++] + }, // [!code ++] + { // [!code ++] + "source": "^/reviews/", // [!code ++] + "destination": "reviews-api", // [!code ++] + "csrfProtection": true // [!code ++] + } // [!code ++] + ] +} +``` +```json [Java] { "routes": [ { // [!code --] @@ -882,32 +919,32 @@ The _xs-app.json_ file describes how to forward incoming request to the API endp "csrfProtection": true // [!code --] } // [!code --] { // [!code ++] - "source": "^/admin/(.*)$", // [!code ++] - "target": "/admin/$1", // [!code ++] + "source": "^/admin/", // [!code ++] "destination": "bookstore-api", // [!code ++] "csrfProtection": true // [!code ++] }, // [!code ++] { // [!code ++] - "source": "^/browse/(.*)$", // [!code ++] - "target": "/browse/$1", // [!code ++] + "source": "^/browse/", // [!code ++] "destination": "bookstore-api", // [!code ++] "csrfProtection": true // [!code ++] }, // [!code ++] { // [!code ++] - "source": "^/user/(.*)$", // [!code ++] - "target": "/user/$1", // [!code ++] + "source": "^/user/", // [!code ++] "destination": "bookstore-api", // [!code ++] "csrfProtection": true // [!code ++] }, // [!code ++] { // [!code ++] - "source": "^/odata/v4/orders/(.*)$", // [!code ++] - "target": "/odata/v4/orders/$1", // [!code ++] + "source": "^/odata/v4/sap.capire.orders.api.OrdersService/", // [!code ++] "destination": "orders-api", // [!code ++] "csrfProtection": true // [!code ++] }, // [!code ++] { // [!code ++] - "source": "^/reviews/(.*)$", // [!code ++] - "target": "/reviews/$1", // [!code ++] + "source": "^/odata/v4/sap.capire.reviews.app.ReviewsService/", // [!code ++] + "destination": "reviews-api", // [!code ++] + "csrfProtection": true // [!code ++] + }, // [!code ++] + { // [!code ++] + "source": "^/odata/v4/sap.capire.reviews.api.ReviewsService/", // [!code ++] "destination": "reviews-api", // [!code ++] "csrfProtection": true // [!code ++] } // [!code ++] From 89d9cee4519914d1543ada7218e4fda35329a681 Mon Sep 17 00:00:00 2001 From: Vladislav Leonkev Date: Mon, 29 Dec 2025 18:17:15 +0100 Subject: [PATCH 18/18] improve --- guides/deploy/microservices.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/deploy/microservices.md b/guides/deploy/microservices.md index 6c1f2db1b7..8dc674e7fa 100644 --- a/guides/deploy/microservices.md +++ b/guides/deploy/microservices.md @@ -869,7 +869,7 @@ modules: ``` ::: -The _xs-app.json_ file describes how to forward incoming request to the API endpoint / OData services and is located in the _.deploy/app-router_ folder. Each exposed CAP Service endpoint needs to be directed to the corresponding application which is providing this CAP service. Modify the file _.deploy/app-router/xs-app.json_ as follows: +The _xs-app.json_ file describes how to forward incoming request to the API endpoint / OData services and is located in the _.deploy/app-router_ folder. Each exposed CAP Service endpoint needs to be directed to the corresponding application that provides this CAP service. Modify the _.deploy/app-router/xs-app.json_ file as follows: ::: code-group ```json [Node.js]