fix api destination update
1 file changed
tree: c58994820f60c916ed777cfe9f2fc66e0695ee47
  1. .github/
  2. adapter/
  3. bin/
  4. common/
  5. docs/
  6. domain/
  7. infrastructure/
  8. start/
  9. style/
  10. supports/
  11. test/
  12. .asf.yaml
  13. .gitignore
  14. .licenserc.yaml
  15. LICENSE
  16. NOTICE
  17. pom.xml
  18. README.md
README.md

Apache RocketMQ EventBridge

RocketMQ EventBridge is a subproject of rocketmq to make it easier to build event-driven applications. In addition, rocketmq-eventbridge can route events between many services and applications based on the standard CloudEvents 1.0 specification. Users can use rocketmq-eventbridge to build loosely coupled and distributed event-driven architectures.

Architecture

Events are sent to the event bus in two ways: 1) Push events through the SDK or Webhook actively; 2) Pulled events by eventbridge passively. Events obtained in both ways will be stored on the event bus. EventBus is the core concept in EventBridge, which allows you to subscribe to the events, filter the events, and push to the specified target by creating the event rule. The event on the event bus is stored by rocketmq. Through rocketmq-connect, we can pull the event from the register source to the event bus, or push the events from the event bus to the registered target.

The code architecture of EventBridge include 4 core modules:

  • adapter Adapt to different operating environments
    • persistence Implement the repository API in the domain layer and persist the model data.
    • api The open API provided by EventBridge.
    • rpc Implement the rpc API in the domain layer to adapter the run environment.
  • common The common code of all modules.
  • domain The core code of EventBridge.
    • model:The core properties and behaviors of model on EventBridge.
    • service: The domain services which across multiple domains.
  • start

Quick Start

RocketMQ EventBridge rely on a message service to store the event, and needs one connect service to collect or forward events.Here, we choose the Apache RocketMQ as our message service, and choose the Apache RocketMQ Connect as our connect service.Of course, you can also choose other alternative services. Eventbridge do not limit it. You only need to provide the relevant adapter API implementation.

Apache RocketMQ

Apache RocketMQ is a great messaging service,and we choose it as our message service.You can deploy the apache rocketmq according to the manual: RocketMQ Quick Start

Apache RocketMQ Connect

Apache RocketMQ Connect can connect the external upstream and downstream services,and You can deploy it according to the manual: RocketMQ Connect Quick Start . Before deploy the Apache RocketMQ Connect, you should download the plugins below and put it to the “pluginpath” which defined on rocketmq-connect.

Apache RocketMQ EventBridge

Before run the project,configure the following properties which :

# The config of mysql databse.
spring.datasource.url=jdbc:mysql://xxxx:3306/xxxx?characterEncoding=utf8
spring.datasource.username=xxx
spring.datasource.password=xxxx

# The endpoint of rocketmq nameserver.
rocketmq.namesrvAddr=xxxxx:9876

# The cluster name of rocketmq.
rocketmq.cluster.name=DefaultCluster
runtime.pluginpath=xxxx

Config the runtime.pluginpath to set the directory of plugin.

Demo

  • Put Events to EventBus The system creates a demo bus by default, and you can send events directly to the bus.
curl  -X POST http://127.0.0.1:7001/putEvents  \
-H "Content-Type: application/json; charset=UTF-8"  \
-H "ce-specversion:1.0"  \
-H "ce-type:com.github.pull_request.opened"  \
-H "ce-source:https://github.com/cloudevents/spec/pull"  \
-H "ce-subject:demo"  \
-H "ce-id:1234-1234-1234"  \
-H "ce-datacontenttype:application/json"  \
-H "ce-time:2018-04-05T17:31:00Z"  \
-H "ce-eventbusname:demo-bus"  \
-d 'A test recrod.'
  • Check if the local file received a write event

In addition, by default, the system will create a demo rule for you to subscribe and push to the file. You can check whether there are events received in the directory:~/demo img.png

Why does the file output the data attribute of CloudEvent instead of other attributes?This is because the configuration in the demo rule is to output “$.data” in CloudEvent to the file line. You can refer to this document to configure and modify event targets.