You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eventmesh.apache.org by ch...@apache.org on 2026/09/18 07:52:58 UTC
(eventmesh-site) branch master updated: [ISSUE apache/eventmesh#4613] [Doc] Add Spring connector documentation (#265)
This is an automated email from the ASF dual-hosted git repository.
qqeasonchen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/eventmesh-site.git
The following commit(s) were added to refs/heads/master by this push:
new 60aece84e [ISSUE apache/eventmesh#4613] [Doc] Add Spring connector documentation (#265)
60aece84e is described below
commit 60aece84e746641493e759fc56037b3a15e7f5f9
Author: Abdullah <89...@users.noreply.github.com>
AuthorDate: Fri Sep 18 10:52:51 2026 +0300
[ISSUE apache/eventmesh#4613] [Doc] Add Spring connector documentation (#265)
Document eventmesh-connector-spring under design-document/03-connect (EN+ZH).
---
.../03-connect/16-spring-connector.md | 103 +++++++++++++++++++++
.../03-connect/16-spring-connector.md | 103 +++++++++++++++++++++
2 files changed, 206 insertions(+)
diff --git a/docs/design-document/03-connect/16-spring-connector.md b/docs/design-document/03-connect/16-spring-connector.md
new file mode 100644
index 000000000..a35243fb1
--- /dev/null
+++ b/docs/design-document/03-connect/16-spring-connector.md
@@ -0,0 +1,103 @@
+# Spring
+
+`eventmesh-connector-spring` is a Spring Boot starter, not a standalone `main()` connector. Add the module to a Spring Boot application. `EventMeshAutoConfiguration` registers the source, sink, and connect-server beans.
+
+The source takes objects from your application (`SpringSourceConnector.send`) and publishes them to EventMesh. The sink takes events from EventMesh and delivers them to methods annotated with `@EventMeshListener`.
+
+## SpringSinkConnector: From EventMesh to Spring
+
+1. Start EventMesh Runtime.
+2. Enable the sink (`sinkEnable: true` in `server-config.yml`) and check `sink-config.yml`.
+3. Start the Spring Boot application that depends on `eventmesh-connector-spring`. `EventMeshListenerBeanPostProcessor` starts `SpringSinkConnector` and invokes each `@EventMeshListener` method with records from the sink queue.
+4. Send a message to EventMesh on `pubSubConfig.subject`; the listener method receives it.
+
+```java
+@Component
+public class SpringSubHandler {
+
+ @EventMeshListener
+ public void onMessage(String message) {
+ // handle payload
+ }
+}
+```
+
+```yaml
+pubSubConfig:
+ meshAddress: 127.0.0.1:10000
+ subject: TEST-TOPIC-SPRING
+ idc: FT
+ env: PRD
+ group: springSink
+ appId: 5033
+ userName: springSinkUser
+ passWord: springPassWord
+sinkConnectorConfig:
+ connectorName: springSink
+```
+
+## SpringSourceConnector: From Spring to EventMesh
+
+1. Start EventMesh Runtime.
+2. Enable the source (`sourceEnable: true` in `server-config.yml`) and check `source-config.yml`.
+3. Start the Spring Boot application. `SpringConnectServer` (a `CommandLineRunner`) starts `SpringSourceConnector`. Inject that bean and call `send`.
+4. The payload is published to `pubSubConfig.subject` in EventMesh Runtime.
+
+```java
+@RestController
+public class SpringPubController {
+
+ @Autowired
+ private SpringSourceConnector springSourceConnector;
+
+ @RequestMapping("/spring/pub")
+ public String publish() {
+ springSourceConnector.send("{\"content\":\"testSpringPublishMessage\"}");
+ return "success!";
+ }
+}
+```
+
+```yaml
+pubSubConfig:
+ meshAddress: 127.0.0.1:10000
+ subject: TEST-TOPIC-SPRING
+ idc: FT
+ env: PRD
+ group: springSource
+ appId: 5033
+ userName: springSourceUser
+ passWord: springPassWord
+sourceConnectorConfig:
+ connectorName: springSource
+```
+
+### Configuration
+
+`pubSubConfig` is the EventMesh TCP client used to publish into or subscribe from Runtime.
+
+`sourceConnectorConfig` / `sinkConnectorConfig` fields:
+
+- `connectorName`: name of the connector.
+
+`server-config.yml`:
+
+- `sourceEnable`: start `SpringSourceConnector` from `SpringConnectServer`.
+- `sinkEnable`: start `SpringSinkConnector` from `EventMeshListenerBeanPostProcessor`.
+
+`@EventMeshListener.requestTimeout` is the queue poll timeout in seconds (default 5).
+
+Spring environment properties whose keys start with `eventmesh.connector.` are copied onto source records as extensions (prefix stripped, key lowercased).
+
+### Precautions
+
+- This module cannot run on its own. Depend on it from a Spring Boot application (`META-INF/spring.factories` auto-configuration).
+- Bundled `server-config.yml` sets `sourceEnable: true` and `sinkEnable: true`. Turn off the side you are not running.
+- Bundled `source-config.yml` / `sink-config.yml` use a `connectorConfig` key. Jackson binds `sourceConnectorConfig` and `sinkConnectorConfig` on the Java config classes; use those field names.
+- `SpringConnectServer` starts only the source worker. The sink worker is started by `EventMeshListenerBeanPostProcessor`, not by `SpringConnectServer`.
+- `@EventMeshListener` methods must take exactly one argument. `String` receives the payload bytes as text; any other type is JSON-deserialized.
+- See `eventmesh-examples` (`SpringPubController` / `SpringSubHandler`) for a full sample.
+
+### Official references
+
+- [Spring Boot auto-configuration](https://docs.spring.io/spring-boot/reference/using/auto-configurations.html)
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/design-document/03-connect/16-spring-connector.md b/i18n/zh/docusaurus-plugin-content-docs/current/design-document/03-connect/16-spring-connector.md
new file mode 100644
index 000000000..306d57276
--- /dev/null
+++ b/i18n/zh/docusaurus-plugin-content-docs/current/design-document/03-connect/16-spring-connector.md
@@ -0,0 +1,103 @@
+# Spring
+
+`eventmesh-connector-spring` 是 Spring Boot starter,不是独立的 `main()` 连接器。把它加到 Spring Boot 应用里,`EventMeshAutoConfiguration` 会注册 Source、Sink 和 connect-server Bean。
+
+Source 从应用里取出对象(`SpringSourceConnector.send`)并发布到 EventMesh。Sink 从 EventMesh 接收事件,交给带 `@EventMeshListener` 的方法。
+
+## SpringSinkConnector:从 EventMesh 到 Spring
+
+1. 启动 EventMesh Runtime。
+2. 启用 sink(在 `server-config.yml` 中设置 `sinkEnable: true`)并检查 `sink-config.yml`。
+3. 启动依赖 `eventmesh-connector-spring` 的 Spring Boot 应用。`EventMeshListenerBeanPostProcessor` 会启动 `SpringSinkConnector`,并从 sink 队列取出记录调用每个 `@EventMeshListener` 方法。
+4. 向 EventMesh 的 `pubSubConfig.subject` 发送消息后,监听方法会收到它。
+
+```java
+@Component
+public class SpringSubHandler {
+
+ @EventMeshListener
+ public void onMessage(String message) {
+ // handle payload
+ }
+}
+```
+
+```yaml
+pubSubConfig:
+ meshAddress: 127.0.0.1:10000
+ subject: TEST-TOPIC-SPRING
+ idc: FT
+ env: PRD
+ group: springSink
+ appId: 5033
+ userName: springSinkUser
+ passWord: springPassWord
+sinkConnectorConfig:
+ connectorName: springSink
+```
+
+## SpringSourceConnector:从 Spring 到 EventMesh
+
+1. 启动 EventMesh Runtime。
+2. 启用 source(在 `server-config.yml` 中设置 `sourceEnable: true`)并检查 `source-config.yml`。
+3. 启动 Spring Boot 应用。`SpringConnectServer`(`CommandLineRunner`)会启动 `SpringSourceConnector`。注入该 Bean 并调用 `send`。
+4. 消息会发布到 EventMesh Runtime 中 `pubSubConfig.subject` 指定的 Topic。
+
+```java
+@RestController
+public class SpringPubController {
+
+ @Autowired
+ private SpringSourceConnector springSourceConnector;
+
+ @RequestMapping("/spring/pub")
+ public String publish() {
+ springSourceConnector.send("{\"content\":\"testSpringPublishMessage\"}");
+ return "success!";
+ }
+}
+```
+
+```yaml
+pubSubConfig:
+ meshAddress: 127.0.0.1:10000
+ subject: TEST-TOPIC-SPRING
+ idc: FT
+ env: PRD
+ group: springSource
+ appId: 5033
+ userName: springSourceUser
+ passWord: springPassWord
+sourceConnectorConfig:
+ connectorName: springSource
+```
+
+### 配置项
+
+`pubSubConfig` 是与 Runtime 交互的 EventMesh TCP 客户端配置。
+
+`sourceConnectorConfig` / `sinkConnectorConfig` 字段:
+
+- `connectorName`:连接器名称。
+
+`server-config.yml`:
+
+- `sourceEnable`:由 `SpringConnectServer` 启动 `SpringSourceConnector`。
+- `sinkEnable`:由 `EventMeshListenerBeanPostProcessor` 启动 `SpringSinkConnector`。
+
+`@EventMeshListener.requestTimeout` 是队列 poll 超时(秒,默认 5)。
+
+以 `eventmesh.connector.` 开头的 Spring 环境属性会写到 Source 记录的 extension 上(去掉前缀并把 key 转成小写)。
+
+### 注意事项
+
+- 该模块不能单独运行。需要作为 Spring Boot 应用的依赖(`META-INF/spring.factories` 自动配置)。
+- 自带的 `server-config.yml` 中 `sourceEnable: true`、`sinkEnable: true`。不需要的一侧请关掉。
+- 自带的 `source-config.yml` / `sink-config.yml` 使用 `connectorConfig`。Java 配置类上 Jackson 绑定的是 `sourceConnectorConfig` 和 `sinkConnectorConfig`,请用这两个字段名。
+- `SpringConnectServer` 只启动 source worker。sink worker 由 `EventMeshListenerBeanPostProcessor` 启动,不是 `SpringConnectServer`。
+- `@EventMeshListener` 方法必须恰好一个参数。`String` 按文本接收 payload 字节;其他类型按 JSON 反序列化。
+- 完整示例见 `eventmesh-examples`(`SpringPubController` / `SpringSubHandler`)。
+
+### 官方参考
+
+- [Spring Boot 自动配置](https://docs.spring.io/spring-boot/reference/using/auto-configurations.html)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: commits-help@eventmesh.apache.org