CloudEvents Integration
Introduction
CloudEvents is a specification for describing event data in common formats to provide interoperability across services, platforms and systems.
As of May 2021, EventMesh contains the following major components: eventmesh-runtime, eventmesh-sdk-java and eventmesh-connector-rocketmq.
For a customer to use EventMesh, eventmesh-runtime can be deployed as microservices to transmit
customer’s events between event producers and consumers. Customer’s applications can then interact
with eventmesh-runtime using eventmesh-sdk-java to publish/subscribe for events on given topics.
CloudEvents support has been a highly desired feature by EventMesh users. There are many reasons for users to prefer using a SDK with CloudEvents support:
- CloudEvents is a more widely accepted and supported way to describe events. eventmesh-sdk-javacurrently uses theEventMeshMessagestructure to describe events, which is less standardized.
- CloudEvents’s Java SDK has a wider range of distribution methods. For example, EventMesh users currently need to use the SDK tarball or build from source for every EventMesh release. With CloudEvents support, it’s easier for users to take a dependency on EventMesh’s SDK using CloudEvents’s public distributions (e.g. through a Maven configuration).
- CloudEvents’s SDK supports multiple languages. Although EventMesh currently only supports a Java SDK, in future if more languages need to be supported, the extensions can be easier with experience on binding Java SDK with CloudEvents.
Requirements
Functional Requirements
| Requirement ID | Requirement Description | Comments | 
|---|---|---|
| F-1 | EventMesh users should be able to depend on a public SDK to publish/subscribe events in CloudEvents format | Functionality | 
| F-2 | EventMesh users should continue to have access to existing EventMesh client features (e.g. load balancing) with an SDK that supports CloudEvent | Feature Parity | 
| F-3 | EventMesh developers should be able to sync eventmesh-sdk-javaand an SDK with CloudEvents support without much effort/pain | Maintainability | 
| F-4 | EventMesh support pluggable protocols for developers integrate other protocols (e.g. CloudEvents\EventMesh Message\OpenMessage\MQTT …) | Functionality | 
| F-5 | EventMesh support the unified api for publish/subscribe events to/from Event Store | Functionality | 
Performance Requirements
| Requirement ID | Requirement Description | Comments | 
|---|---|---|
| P-1 | Client side latency for SDK with CloudEvents support should be similar to current SDK | 
Design Details
Binding with the CloudEvents Java SDK (similar to what Kafka already did, see Reference for more details) should be an easy way to achieve the requirements.
Pluggable Protocols

Process of CloudEvents under EventMesh
For TCP
SDK side for publish
- add the CloudEvents identifier in packageheader
- use CloudEventBuilderbuild the CloudEvent and put it into thepackagebody
SDK side for subscribe
- add convertfunction under theReceiveMsgHookinterface, for converting thepackagebody to the specific protocol with the identifier inpackageheader
- different protocols should implement the ReceiveMsgHookinterface
Server side for publish
- design the protocol convert api contains decodeMessageinterface which convert the package’s body to CloudEvent
- update Session.upstreamMsg()inMessageTransferTaskchange the input parameter Message to CloudEvent, the CloudEvent use the last stepdecodeMessageapi convert
- update SessionSender.send()change the input parameterMessagetoCloudEvent
- update MeshMQProducerapi support sendCloudEventsin runtime
- support the implementation in connector-pluginfor sendCloudEventsto EventStore
Server side for subscribe
- support change the - RocketMessageto- CloudEventin connector-plugin
- overwrite the - AsyncMessageListener.consume()function, change the input parameter- Messageto- CloudEvent
- update the - MeshMQPushConsumer.updateOffset()implementation change the the input parameter- Messageto- CloudEvent
- update - DownStreamMsgContext, change the input parameter- Messageto- CloudEvent, update the- DownStreamMsgContext.ackMsg
For HTTP
SDK side for publish
- support LiteProducer.publish(cloudEvent)
- add the CloudEvents identifier in http request header
SDK side for subscribe
Server side for publish
- support build the HttpCommand.bodyby pluggable protocol plugins according the protocol type inHttpCommandheader
- support publish the CloudEvent in message processors
Server side for subscribe
- update the - EventMeshConsumer.subscribe()
- update - HandleMsgContext, change the input parameter- Messageto- CloudEvent
- update AsyncHttpPushRequest.tryHTTPRequest()
 我的书签
 我的书签
                                 添加书签
 添加书签 移除书签
 移除书签