Connect java spring boot app to SAP event mesh (BTP)

938 Views Asked by At

I'm currently trying to connect a java application (running on premise) to the SAP event mesh to receive messages published by some SAP system.

The colleagues provided a json file with credentials and endpoints:

{
    "namespace": ":)",
    "xsappname": ":)",
    "management": [
        {
            "oa2": {
                "clientid": ":)",
                "clientsecret": ":)",
                "tokenendpoint": "https://whatever.authentication.eu20.hana.ondemand.com/oauth/token",
                "granttype": "client_credentials"
            },
            "uri": "https://em-hub-backend.cfapps.eu20.hana.ondemand.com"
        }
    ],
    "serviceinstanceid": ":)",
    "messaging": [
        {
            "oa2": {
                "clientid": ":)",
                "clientsecret": ":)",
                "tokenendpoint": "https://whatever.authentication.eu20.hana.ondemand.com/oauth/token",
                "granttype": "client_credentials"
            },
            "protocol": [
                "amqp10ws"
            ],
            "broker": {
                "type": "sapmgw"
            },
            "uri": "wss://em-messaging-gateway.cfapps.eu20.hana.ondemand.com/protocols/amqp10ws"
        },
        {
            "oa2": {
                "clientid": ":)",
                "clientsecret": ":)",
                "tokenendpoint": "https://whatever.authentication.eu20.hana.ondemand.com/oauth/token",
                "granttype": "client_credentials"
            },
            "protocol": [
                "mqtt311ws"
            ],
            "broker": {
                "type": "sapmgw"
            },
            "uri": "wss://em-messaging-gateway.cfapps.eu20.hana.ondemand.com/protocols/mqtt311ws"
        },
        {
            "oa2": {
                "clientid": ":)",
                "clientsecret": ":)",
                "tokenendpoint": "https://whatever.authentication.eu20.hana.ondemand.com/oauth/token",
                "granttype": "client_credentials"
            },
            "protocol": [
                "httprest"
            ],
            "broker": {
                "type": "saprestmgw"
            },
            "uri": "https://em-pubsub.cfapps.eu20.hana.ondemand.com"
        }
    ]
}

According to the SAP help page there are 3 supported protocols (https://help.sap.com/viewer/bf82e6b26456494cbdd197057c09979f/Cloud/en-US/3f424ff1ae3b4bc084c4f1ea0be96f54.html)

  • Advanced Message Queuing Protocol (AMQP) 1.0 over WebSocket
  • Message Queuing Telemetry Transport (MQTT) 3.1.1 over WebSocket
  • REST APIs for Messaging

I guess REST APIs have very bad performance. So I'd go for AMQP or MQTT over WS. It's a bit hard to find a java client library that supports either AMQP or MQTT and secure websockets and oauth authentication.

I already had a look at SAP cloud sdk. But the feature overview tells me that messaging is still in planned state which means it's not available yet.

Do you have any suggestions how I can make progress here?

1

There are 1 best solutions below

0
On

UPD: my colleagues have recommended the XBEM library being currently the best option for event consumption from SAP. The libraries by CAP and SDK are adding convenience on top of it. Check more docs here.

The SAP Cloud SDK had experimental support for the Enterprise Event mesh for S/4HANA but it was discontinued in favor of implementation by CAP. They promised to release a library that can be used as a dependency to simplify events consumption for both Java and Node.js. It seems to be taking longer than promised, see the current status in the screenshot: enter image description here

When the library is released the SDK plans to provide additional convenience with type-safe access to events. Currently, that's impossible as there's no generally available release.

You can still try out CAP's library if you have a single tenant App. For reference consult their docs

If you'd like to have Enterprise Events mesh support in the SAP Cloud SDK, please, create a feature request here.