{"id":20485011,"url":"https://github.com/sap-samples/event-mesh-client-java-samples","last_synced_at":"2025-04-13T14:52:49.404Z","repository":{"id":44552315,"uuid":"140482108","full_name":"SAP-samples/event-mesh-client-java-samples","owner":"SAP-samples","description":"Samples based on the Java messaging client for SAP Event Mesh (formerly Enterprise Messaging in SAP Cloud Platform).","archived":false,"fork":false,"pushed_at":"2025-03-07T12:53:24.000Z","size":116,"stargazers_count":18,"open_issues_count":3,"forks_count":18,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-27T05:51:10.804Z","etag":null,"topics":["enterprise-messenging","java","sample","sample-code","sap-cloud-platform","sap-event-mesh"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SAP-samples.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-10T20:09:28.000Z","updated_at":"2024-11-04T13:32:37.000Z","dependencies_parsed_at":"2022-09-04T00:31:08.729Z","dependency_job_id":null,"html_url":"https://github.com/SAP-samples/event-mesh-client-java-samples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP-samples%2Fevent-mesh-client-java-samples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP-samples%2Fevent-mesh-client-java-samples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP-samples%2Fevent-mesh-client-java-samples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP-samples%2Fevent-mesh-client-java-samples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SAP-samples","download_url":"https://codeload.github.com/SAP-samples/event-mesh-client-java-samples/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248732509,"owners_count":21152851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["enterprise-messenging","java","sample","sample-code","sap-cloud-platform","sap-event-mesh"],"created_at":"2024-11-15T16:27:01.042Z","updated_at":"2025-04-13T14:52:49.383Z","avatar_url":"https://github.com/SAP-samples.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Messaging Client Java - Samples for SAP Event Mesh\r\n\r\nimage:https://api.reuse.software/info/github.com/SAP-samples/event-mesh-client-java-samples[\"REUSE status\", link=\"https://api.reuse.software/info/github.com/SAP-samples/event-mesh-client-java-samples\"]\r\n\r\n== Note\r\nThe SAP Cloud Platform Enterprise Messaging service has been renamed to SAP Event Mesh - find more information in this link:https://blogs.sap.com/2021/02/22/please-welcome-sap-event-mesh-new-name-for-sap-cloud-platform-enterprise-messaging/[blog article].\r\n\r\n== Description\r\nSAP Event Mesh provides a cloud-based messaging framework for the development of decoupled and resilient services and integration flows (using SAP Cloud Integration) to support asynchronous communication principles.\r\nDirect integration with SAP S/4HANA Business Event Handling allows efficient development of innovative and scaling extensions.\r\n\r\nThis sample demonstrates Event Mesh with Java, using combinations of vanilla Java, Spring, and JMS. Details on each sample application and the covered scenario are described in the table _List of sample projects_ below.\r\n\r\nFor more details of **SAP Event Mesh** take a look at the link:https://help.sap.com/viewer/bf82e6b26456494cbdd197057c09979f/Cloud/en-US/df532e8735eb4322b00bfc7e42f84e8d.html[SAP Event Mesh on SAP Help portal].\r\n\r\n\r\n== Requirements\r\nBelow requirements are necessary for each of the samples.\r\nFurther necessary configuration and settings are dependent on the specific sample and are documented within each sample project.\r\n\r\n  * Installed _Java 8_ -\u003e link:https://java.com/de/download/[Java download]\r\n  * Installed _Git_ -\u003e link:https://git-scm.com/downloads[Git download]\r\n  * Installed _Maven 3.x_ -\u003e link:https://maven.apache.org/download.cgi[Maven download]\r\n  * A _SAP BTP_ Account with `Event Mesh Service` is required. +\r\n    For more detailed information and help on how to start with _SAP Event Mesh_ please check the link:https://help.sap.com/viewer/bf82e6b26456494cbdd197057c09979f/Cloud/en-US/df532e8735eb4322b00bfc7e42f84e8d.html[SAP help page].\r\n    ** Optional: Installed _CloudFoundry CLI_ -\u003e link:https://docs.cloudfoundry.org/cf-cli/install-go-cli.html[Installing the cf CLI] \r\n    *** This must be also fully configured with the corresponding Cloud Foundry landscape to be able to do a `cf push`\r\n    ** Created Event Mesh Service Instance \r\n    *** e.g. via cli: `cf cs enterprise-messaging default emjapi-samples-sapbtp -c` link:./emjapi-samples-jms-p2p/config/[`\u003ccontents of default descriptor\u003e`]\r\n    *** The Service Descriptors can be found link:https://help.sap.com/viewer/bf82e6b26456494cbdd197057c09979f/Cloud/en-US/d0483a9e38434f23a4579d6fcc72654b.html[here]\r\n    *** Remember to adjust the manifest file of the application\r\n    *** Include the ability to create required queues (e.g. `NameOfQueue`) and queue subscriptions (e.g. `NameOfTopic`) via e.g. \r\n    link:https://help.sap.com/viewer/bf82e6b26456494cbdd197057c09979f/Cloud/en-US/57af1bd4e8f54b0a9b36414a5ec6b800.html?q=messaging%20management[MM API],\r\n    link:https://help.sap.com/viewer/bf82e6b26456494cbdd197057c09979f/Cloud/en-US/57af1bd4e8f54b0a9b36414a5ec6b800.html[UI]\r\n\r\n=== Recommended\r\n\r\n  * Installed IDE of choice (e.g. link:https://code.visualstudio.com/[Visual Studio] with installed link:https://marketplace.visualstudio.com/items?itemName=redhat.java[Java language support] plugin)\r\n\r\n=== List of sample projects\r\n\r\n[cols=3*,options=header]\r\n|===\r\n|Application\r\n|Scenario\r\n|Scenario Description\r\n\r\n|link:./emjapi-samples-jms-p2p[`emjapi-samples-jms-p2p`]\r\n|Application for Event Mesh based on Spring Web running on SAP Business Technology Platform (@ CloudFoundry (with Event Mesh Service)).\r\n|This sample demonstrates how messages can be send and received from a SAP BTP deployed application. Therefore the messaging sample provides a _Spring Boot_ based application which provides REST endpoints for _send_ and _receive_ messages via a queue (or queues) of choice. The REST endpoints are provided via the `MessagingServiceRestController`.\r\n\r\n|link:./emjapi-samples-jms-pubsub[`emjapi-samples-jms-pubsub`]\r\n|Application for Event Mesh based on Spring Web running on SAP Business Technology Platform (@ CloudFoundry (with Event Mesh Service)).\r\n|This sample demonstrates how messages can be send and received from a topic from a SAP BTP deployed application. Therefore the messaging sample provides a _Spring Boot_ based application which provides REST endpoints for _send_ and _receive_ messages via a topic of choice. It also offers a REST endpoint to receive a message from a queue. The REST endpoints are provided via the `MessagingServiceRestController`.\r\n\r\n|===\r\n\r\n== Download and Installation\r\nTo download and install the samples just clone this repository via `git clone`\r\n\r\nFor details on how to configure and run the samples please take a look into the README in the corresponding samples directory.\r\n\r\n== Usage of the client\r\n\r\nThis section describes the usage of the client without any sample application. It is described which dependencies are needed and how a `MessagingServiceJmsConnectionFactory` is received in a short way.\r\n\r\n=== Dependencies\r\n\r\nThree different dependencies are needed:\r\n\r\n. the emjapi spring service connector which provides the `MessagingService`\r\n. the emjapi core which creates the connection factory\r\n. the emjapi JMS extension which provides the `MessagingServiceJmsConnectionFactory`\r\n\r\n```xml\r\n\u003cdependency\u003e\r\n\t\u003cgroupId\u003ecom.sap.cloud.servicesdk.xbem\u003c/groupId\u003e\r\n\t\u003cartifactId\u003eemjapi-connector-sap-cp\u003c/artifactId\u003e\r\n\t\u003cversion\u003e${version.xbem.client}\u003c/version\u003e\r\n\u003c/dependency\u003e\r\n\r\n\u003cdependency\u003e\r\n\t\u003cgroupId\u003ecom.sap.cloud.servicesdk.xbem\u003c/groupId\u003e\r\n\t\u003cartifactId\u003eemjapi-core\u003c/artifactId\u003e\r\n\t\u003cversion\u003e${version.xbem.client}\u003c/version\u003e\r\n\u003c/dependency\u003e\r\n\r\n\u003cdependency\u003e\r\n\t\u003cgroupId\u003ecom.sap.cloud.servicesdk.xbem\u003c/groupId\u003e\r\n\t\u003cartifactId\u003eemjapi-extension-sap-cp-jms\u003c/artifactId\u003e\r\n\t\u003cversion\u003e${version.xbem.client}\u003c/version\u003e\r\n\u003c/dependency\u003e\r\n```\r\n\r\n=== Code snippets\r\n\r\nGet the `MessagingService` via the spring `Cloud` object\r\n\r\n```java\r\nServiceConnectorConfig config = null; // currently there are no configurations for the MessagingServiceFactory supported\r\nCloud cloud = new CloudFactory().getCloud();\r\n// get a messaging service factory via the service connector\r\nMessagingService messagingService = cloud.getSingletonServiceConnector(MessagingService.class, config);\r\n```\r\n\r\nCreate a the `MessagingServiceFactory` object with the help of the `MessagingServiceFactoryCreator` and get a `MessagingServiceJmsConnectionFactory`. \r\nThe Connection Factory can be configured with the `MessagingServiceJmsSettings`. In case the reconnection feature is not needed and an individual \r\nconnection mechanism (e.G. through a connection cache) is used the settings can be skipped. The connection factory can be built with \r\n`messagingServiceFactory.createConnectionFactory(MessagingServiceJmsConnectionFactory.class,settings)`.\r\n\r\n```java\r\nMessagingServiceJmsSettings settings = new MessagingServiceJmsSettings(); // settings are preset with default values (see JavaDoc)\r\nsettings.setMaxReconnectAttempts(5); // use -1 for unlimited attempts\r\nsettings.setInitialReconnectDelay(3000);\r\nsettings.setReconnectDelay(3000);\r\nMessagingServiceFactory messagingServiceFactory = MessagingServiceFactoryCreator.createFactory(messagingService);\r\nMessagingServiceJmsConnectionFactory connectionFactory = messagingServiceFactory.createConnectionFactory(MessagingServiceJmsConnectionFactory.class, settings)\r\n```\r\n\r\nFurther the `MessagingServiceJmsConnectionFactory` is used to create a connection and a session.\r\n\r\n```java\r\nConnection connection = connectionFactory.createConnection();\r\nSession session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE));\r\n```\r\n\r\n== Messaging Management API\r\nThe messaging management api (MM API) provides functionality for creating, deleting and updating queues and queue subscriptions.\r\nFurther more it provides APIs to get information on queues and queue subscriptions.\r\nThe MM API documentation can be found link:https://help.sap.com/doc/75c9efd00fc14183abc4c613490c53f4/Cloud/en-US/rest-management-messaging.html[here]. \r\nThe MM APIs have to be enabled in the service descriptor. A description for enabling the MM API can be found link:https://help.sap.com/viewer/bf82e6b26456494cbdd197057c09979f/Cloud/en-US/d0483a9e38434f23a4579d6fcc72654b.html[here].\r\n\r\n== Creation of queues with the UI\r\nQueues can be created through the SAP Business Technology Platform Cockpit UI.\r\nMore information regarding the creation of queues through the UI can be found link:https://help.sap.com/viewer/bf82e6b26456494cbdd197057c09979f/Cloud/en-US/57af1bd4e8f54b0a9b36414a5ec6b800.html[here]\r\n\r\n== Service Descriptor\r\nExamples for the different service descriptors can be found link:https://help.sap.com/viewer/bf82e6b26456494cbdd197057c09979f/Cloud/en-US/d0483a9e38434f23a4579d6fcc72654b.html[here] on the help site\r\nand in the config folder of this project.\r\n\r\n== Contributing\r\nThis project is _'as-is'_ with no support, no changes being made. +\r\nYou are welcome to make changes to improve it but we are not available for questions or support of any kind.\r\n\r\n== Licensing\r\nCopyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. +\r\nThis project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the link:./LICENSES/Apache-2.0.txt[LICENSE file].\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsap-samples%2Fevent-mesh-client-java-samples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsap-samples%2Fevent-mesh-client-java-samples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsap-samples%2Fevent-mesh-client-java-samples/lists"}