This is an automated email from the ASF dual-hosted git repository.
shenlin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/rocketmq-eventbridge.git
The following commit(s) were added to refs/heads/main by this push:
new fdab180 feat: support auto init source/target class. (#26)
fdab180 is described below
commit fdab180b96de8913c5b0702c9752fd939880a756
Author: shenlin <[email protected]>
AuthorDate: Mon Jul 4 15:01:12 2022 +0800
feat: support auto init source/target class. (#26)
feat: support auto init source/target class.
---
README.md | 134 ++++-----------------
.../db/migration/V3__register_source_acs_mns.sql | 1 +
.../V4__register_target_acs_eventbridge.sql | 3 +
.../migration/V5__register_target_acs_dingtalk.sql | 3 +
start/src/main/resources/application.properties | 1 +
5 files changed, 30 insertions(+), 112 deletions(-)
diff --git a/README.md b/README.md
index f58c4a4..d78d934 100644
--- a/README.md
+++ b/README.md
@@ -49,104 +49,13 @@ rocketmq.cluster.name=DefaultCluster
rocketmq.connect.endpoint=xxxxxx:8082
```
-After that ,you should register the targets which you want to create, into the
'event_target_class' table.
-
-| key | description |
-| ----------------------------------------------- | -------- |
-| name | the target class name |
-|api_params | the required params when create target. |
-|target_transform |the default transform with target data. |
-|required_params |the required params of connect. |
-
-
-* register the "acs.eventbridge" target.
-
-api_params:
-```json
-{
- "RegionId":{
- "type":"String",
- "desc":"the region of aliyun eventbridge.",
- "required":true
- },
- "AliyunEventBus":{
- "type":"String",
- "desc":"the bus of aliyun eventbridge.",
- "required":true
- }
-}
-```
-
-target_transform:
-```json
-{
- "data":"{\"form\":\"JSONPATH\",\"value\":\"$.data\"}",
- "id":"{\"form\":\"JSONPATH\",\"value\":\"$.id\"}",
- "type":"{\"form\":\"JSONPATH\",\"value\":\"$.type\"}",
- "specversion":"{\"form\":\"JSONPATH\",\"value\":\"$. specversion\"}",
- "subject":"{\"form\":\"JSONPATH\",\"value\":\"$.subject\"}",
- "source":"{\"form\":\"JSONPATH\",\"value\":\"$.source\"}"
-}
-```
-
-
-required_params:
-```json
-{
- "aliyuneventbusname":"${AliyunEventBus}",
- "accessKeyId":"the accessKeyId of aliyun accountId",
- "accessKeySecret":"the accessKeySecret of aliyun accountId",
- "accountEndpoint":"xxxx.eventbridge.${RegionId}.aliyuncs.com",
-
"class":"org.apache.rocketmq.connect.eventbridge.sink.EventBridgeSinkConnector"
-}
-```
-
-* register the "acs.dingtalk" target.
-
-
-api_params:
-```json
-{
- "WebHook":{
- "type":"String",
- "desc":"the webhook endpoint of dingtalk.",
- "required":true
- },
- "SecretKey":{
- "type":"String",
- "desc":"the secret key of dingtalk webhookd.",
- "required":true
- },
- "Body":{
- "type":"boolean",
- "desc":"the content which push to dingtalk."
- }
-}
-```
-
-target_transform:
-```json
-{
- "data":"${Body}"
-}
-```
-
-
-target_transform:
-```json
-{
- "webHook":"${WebHook}",
- "secretKey":"${SecretKey}",
- "class":"org.apache.rocketmq.connect.dingtalk.sink.DingTalkSinkConnector"
-}
-```
## Demo
####
* Create EventBus
-```json
+```text
POST /bus/createEventBus HTTP/1.1
Host: demo.eventbridge.com
Content-Type: application/json; charset=utf-8
@@ -159,7 +68,7 @@ Content-Type: application/json; charset=utf-8
* Create EventSource
-```json
+```text
POST /source/createEventSource HTTP/1.1
Host: demo.eventbridge.com
Content-Type: application/json; charset=utf-8
@@ -172,7 +81,7 @@ Content-Type: application/json; charset=utf-8
* Create EventRule
-```json
+```text
POST /rule/createEventRule HTTP/1.1
Host: demo.eventbridge.com
Content-Type: application/json; charset=utf-8
@@ -187,28 +96,28 @@ Content-Type: application/json; charset=utf-8
* Create Target
This is a sample with EventBridge target:
-```json
+```text
POST /target/createEventTargets HTTP/1.1
Host: demo.eventbridge.com
Content-Type: application/json; charset=utf-8
{
-"eventBusName":"demo-bus",
-"eventRuleName":"demo-rule",
-"eventTargets":[
- {
- "eventTargetName":"eventbridge-target",
- "className":"acs.eventbridge",
- "config":{
- "RegionId":"cn-hangzhou",
- "AliyunEventBus":"rocketmq-eventbridge"
+ "eventBusName":"demo-bus",
+ "eventRuleName":"demo-rule",
+ "eventTargets":[
+ {
+ "eventTargetName":"eventbridge-target",
+ "className":"acs.eventbridge",
+ "config":{
+ "RegionId":"cn-hangzhou",
+ "AliyunEventBus":"rocketmq-eventbridge"
+ }
}
- }
- ]
+ ]
}
```
This is a sample with DingTalk target:
-```json
+```text
POST /target/createEventTargets HTTP/1.1
Host: demo.eventbridge.com
Content-Type: application/json; charset=utf-8
@@ -231,7 +140,7 @@ Content-Type: application/json; charset=utf-8
* Put Events to EventBus
-```json
+```text
POST /putEvents HTTP/1.1
Host: demo.eventbridge.com
Content-Type:"application/cloudevents+json; charset=UTF-8"
@@ -269,10 +178,11 @@ Here is an example explaining how to put events using
EventBridge HttpSource.
- Referer: Referer security configuration. HTTP requests whose referer is
not in this configuration will be filtered if the security configuration is
selected as 'referer'.
A webhook will be generated after the creation of HttpSource.
-```
-http://127.0.0.1:7001/source/createEventSource
-```
-```json
+
+```text
+POST /source/createEventSource HTTP/1.1
+Host: demo.eventbridge.com
+Content-Type: application/json; charset=utf-8
{
"eventSourceName": "httpEventSourceDemo",
"eventBusName": "demo",
diff --git
a/adapter/persistence/src/main/resources/db/migration/V3__register_source_acs_mns.sql
b/adapter/persistence/src/main/resources/db/migration/V3__register_source_acs_mns.sql
new file mode 100644
index 0000000..04fe627
--- /dev/null
+++
b/adapter/persistence/src/main/resources/db/migration/V3__register_source_acs_mns.sql
@@ -0,0 +1 @@
+INSERT INTO `event_source_class`
(`name`,`api_params`,`required_params`,`transform`,`visual_config`,`description`,`gmt_create`,`gmt_modify`)
VALUES ('acs.mns','{\n \"RegionId\":{\n \"type\":\"String\",\n
\"desc\":\"the region of aliyun mns.\",\n \"required\":true,\n
\"defaultValue\":\"\"\n },\n \"QueueName\":{\n
\"type\":\"String\",\n \"desc\":\"the queue name of aliyun mns.\",\n
\"required\":true,\n \"defaultValue\":\"\"\n [...]
diff --git
a/adapter/persistence/src/main/resources/db/migration/V4__register_target_acs_eventbridge.sql
b/adapter/persistence/src/main/resources/db/migration/V4__register_target_acs_eventbridge.sql
new file mode 100644
index 0000000..605147d
--- /dev/null
+++
b/adapter/persistence/src/main/resources/db/migration/V4__register_target_acs_eventbridge.sql
@@ -0,0 +1,3 @@
+INSERT INTO `event_target_class`
(`name`,`api_params`,`target_transform`,`required_params`,`visual_config`,`description`,`gmt_create`,`gmt_modify`)
+VALUES
+('acs.eventbridge','{\n \"RegionId\":{\n \"type\":\"String\",\n
\"desc\":\"the region of aliyun eventbridge.\",\n \"required\":true\n
},\n \"AliyunAccountId\":{\n \"type\":\"String\",\n
\"desc\":\"the account id of aliyun eventbridge.\",\n
\"required\":true\n },\n \"AliyunEventBus\":{\n
\"type\":\"String\",\n \"desc\":\"the bus of aliyun eventbridge.\",\n
\"required\":true\n },\n \"AccessKeyId\":{\n [...]
diff --git
a/adapter/persistence/src/main/resources/db/migration/V5__register_target_acs_dingtalk.sql
b/adapter/persistence/src/main/resources/db/migration/V5__register_target_acs_dingtalk.sql
new file mode 100644
index 0000000..166d437
--- /dev/null
+++
b/adapter/persistence/src/main/resources/db/migration/V5__register_target_acs_dingtalk.sql
@@ -0,0 +1,3 @@
+INSERT INTO `event_target_class`
(`name`,`api_params`,`target_transform`,`required_params`,`visual_config`,`description`,`gmt_create`,`gmt_modify`)
+VALUES
+('acs.dingtalk','{\n \"WebHook\":{\n \"type\":\"String\",\n
\"desc\":\"the endpoint of webhook.\",\n \"required\":true\n },\n
\"SecretKey\":{\n \"type\":\"String\",\n \"desc\":\"the secret
key.\",\n \"required\":true\n },\n \"Body\":{\n
\"type\":\"boolean\",\n \"desc\":\"the content of request\"\n
}\n}','{ \"data\":\"${Body}\" }','{\n \"webHook\":\"${WebHook}\",\n
\"secretKey\":\"${SecretKey}\",\n \"cl [...]
\ No newline at end of file
diff --git a/start/src/main/resources/application.properties
b/start/src/main/resources/application.properties
index 96d9e16..db2a440 100644
--- a/start/src/main/resources/application.properties
+++ b/start/src/main/resources/application.properties
@@ -6,6 +6,7 @@
spring.datasource.url=jdbc:mysql://localhost:3306/rocketmq-eventbridge?useUnicod
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.username=*****
spring.datasource.password=*****
+spring.flyway.placeholderReplacement=false
mybatis.mapper-locations=classpath:mybatis/*.xml
## rocketmq
rocketmq.namesrvAddr=localhost:9876