Skip to content

Commit

Permalink
[Issue apache#417] Create getting started instructions for Grpc trans…
Browse files Browse the repository at this point in the history
…port procotol
  • Loading branch information
jinrongluo committed Jan 12, 2022
1 parent 22f9930 commit 96306f7
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ sudo vi eventmesh.properties
|----------------------------|-------|----------------------------|
| eventMesh.server.http.port | 10105 | EventMesh http server port |
| eventMesh.server.tcp.port | 10000 | EventMesh tcp server port |

| eventMesh.server.grpc.port | 10205 | EventMesh grpc server port |


### 配置 rocketmq-client.properties
Expand Down
1 change: 1 addition & 0 deletions docs/cn/instructions/eventmesh-runtime-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ eventMesh.connector.plugin.type=rocketmq
| ---------------------- | ------ | ----------------------- |
| eventMesh.server.http.port | 10105 | EventMesh http 服务端口 |
| eventMesh.server.tcp.port | 10000 | EventMesh tcp 服务端口 |
| eventMesh.server.grpc.port | 10205 | EventMesh grpc 服务端口 |

**rocketmq-client.properties**

Expand Down
53 changes: 51 additions & 2 deletions docs/cn/instructions/eventmesh-sdk-java-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
>
> EventMesh-sdk-java支持异步消息和广播消息。异步消息表示生产者只发送消息,不关心回复消息。广播消息表示生产者发送一次消息,所有订阅广播主题的消费者都将收到消息
>
> EventMesh-sdk-java支持HTTP和TCP协议
> EventMesh-sdk-java支持HTTP,TCP 和 GRPC 协议
TCP 和 HTTP 示例都在**eventmesh-example**模块下
TCP, HTTP 和 GRPC 示例都在**eventmesh-example**模块下

### 1. TCP DEMO

Expand Down Expand Up @@ -70,5 +70,54 @@ TCP 和 HTTP 示例都在**eventmesh-example**模块下
运行org.apache.eventmesh.http.demo.pub.eventmeshmessage.AsyncPublishInstance的主要方法
```

### 3. GRPC 演示

> 对于 GRPC, eventmesh-sdk-java 实现了 Google gRPC 和 Google Protocol Buffers 协议. 它能异步和同步发送事件到 eventmesh-runtime.
> 它可以通过webhook和事件流方式订阅消费事件, 同时也支持Apache CloudEvents 协议.
<h4> 异步事件发送 和 webhook订阅 </h4>

> Async生产者 异步发送事件到 eventmesh-runtime, 不需要等待事件储存到 `event-store`
> 在webhook 消费者, 事件推送到消费者的http endpoint url。这个URL在消费者的 `Subscription` 模型定于. 这方法跟前面的Http eventmsh client类似。
- 在rocketmq 创建主题 TEST-TOPIC-GRPC-ASYNC
- 启动 publisher 发送事件

```
运行 org.apache.eventmesh.grpc.pub.eventmeshmessage.AsyncPublishInstance 的主要方法
```

- 启动 webhook 消费者

```
运行 org.apache.eventmesh.grpc.sub.app.SpringBootDemoApplication 的主要方法
```

<h4> 同步事件发送和事件流订阅 </h4>

> 同步生产者 发送事件到 eventmesh-runtime, 同时等待事件储存到 `event-store`
> 在事件流消费者,事件以流的形式推送到 `ReceiveMsgHook` 客户端。 这方法类似 eventmesh client.
- 在rocketmq 创建主题 TEST-TOPIC-GRPC-RR
- 启动 Request-Reply publisher 发送事件

```
运行 org.apache.eventmesh.grpc.pub.eventmeshmessage.RequestReplyInstance 的主要方法
```

- 启动 stream subscriber

```
运行 org.apache.eventmesh.grpc.sub.EventmeshAsyncSubscribe 的主要方法
```

<h4> 批量事件发布 </h4>

> 批量发布多个事件到 eventmesh-runtime. 这是异步操作
- 在rocketmq 创建主题 TEST-TOPIC-GRPC-ASYNC
- 启动 publisher 来批量发布事件

```
运行 org.apache.eventmesh.grpc.pub.eventmeshmessage.BatchPublishInstance 的主要方法
```
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Some default key-values are listed below:
|----------------------------|---------------|----------------------------|
| eventMesh.server.http.port | 10105 | EventMesh http server port |
| eventMesh.server.tcp.port | 10000 | EventMesh tcp server port |
| eventMesh.server.grpc.port | 10205 | EventMesh grpc server port |



Expand Down
11 changes: 6 additions & 5 deletions docs/en/instructions/eventmesh-runtime-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ cd ../bin
sh start.sh
tail -f ./logs/eventmesh.out
EventMeshTCPServer[port=10000] started
...

HTTPServer[port=10105] started
...
```

EventMeshGrpcServer[port=10205] started
```

## 2 Run Locally

Expand Down Expand Up @@ -98,7 +98,8 @@ eventMesh.connector.plugin.type=rocketmq
running `org.apache.eventmesh.starter.StartUp` main method in eventmesh-starter module.

EventMeshTCPServer[port=10000] started
...

HTTPServer[port=10105] started
...

EventMeshGrpcServer[port=10205] started
```
58 changes: 55 additions & 3 deletions docs/en/instructions/eventmesh-sdk-java-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
>
> Supports async msg and broadcast msg. Async msg means the producer just sends msg and does not care reply msg. Broadcast msg means the producer send msg once and all the consumer subscribed the broadcast topic will receive the msg.
>
> EventMesh-sdk-java supports the protocol of HTTP and TCP.
> EventMesh-sdk-java supports the protocol of TCP, HTTP and GRPC.
TCP demos and HTTP demos are both under the **eventmesh-example** module.
TCP, HTTP and GRPC demos are both under the **eventmesh-example** module.

### 1. TCP DEMO

Expand Down Expand Up @@ -47,7 +47,7 @@ Run the main method of org.apache.eventmesh.tcp.demo.pub.eventmeshmessage.AsyncP

> As to HTTP, eventmesh-sdk-java implements the pub and sub for async event .
>
> In the demo, the field of `content` of the java class `LiteMessage` represents a special protocal, so if you want to use http-client of eventmesh-sdk-java, you just need to design the content of protocal and supply the consumer application at the same time.
> In the demo, the field of `content` of the java class `LiteMessage` represents a special protocal, so if you want to use http-client of eventmesh-sdk-java, you just need to design the content of protocol and supply the consumer application at the same time.
#### Async event

Expand All @@ -70,3 +70,55 @@ Run the main method of org.apache.eventmesh.http.demo.sub.SpringBootDemoApplicat
Run the main method of org.apache.eventmesh.http.demo.pub.eventmeshmessage.AsyncPublishInstance
```

### 3. GRPC DEMO

> As to GRPC, eventmesh-sdk-java implements the Google gRPC and Google Protocol Buffers. It can send events to eventmesh-runtime asynchronously
> and synchronously (using request-reply). It can also subscribe to the events using webhook subscriber and stream subscriber.
> Apache CloudEvents protocol is also supported in the demo.
#### Async event publisher and webhook subscriber

> producer asynchronously send the event to eventmesh-runtime, and don't need to wait for the event is delivered to the `event-store` of the eventmesh runtime
> In webhook subscriber, event is delivered to the http endpoint url that is specified in the `Subscription` model. This is similar to the Http eventmesh client.
- Create topic TEST-TOPIC-GRPC-ASYNC on rocketmq-console
- start publisher to publish to the topic as the following:

```
Run the main method of org.apache.eventmesh.grpc.pub.eventmeshmessage.AsyncPublishInstance
```

- Start webhook subscriber as the following:

```
Run the main method of org.apache.eventmesh.grpc.sub.app.SpringBootDemoApplication
```

#### Sync event publisher and stream subscriber

> producer synchronously send the event to eventmesh-runtime, and wait for the event is delivered to the `event-store` of the eventmesh runtime
> In stream subscriber, event is delivered to the `ReceiveMsgHook` client as serials of event streams. This is similar to the TCP eventmesh client.
- Create topic TEST-TOPIC-GRPC-RR on rocketmq-console
- start Request-Reply publisher to publish to the topic as the following:

```
Run the main method of org.apache.eventmesh.grpc.pub.eventmeshmessage.RequestReplyInstance
```

- Start stream subscriber as the following:

```
Run the main method of org.apache.eventmesh.grpc.sub.EventmeshAsyncSubscribe
```

#### Batch async event publisher

> Batch event publisher can publish several events in a batch to the eventmesh-runtime. This is synchronous operation.
- Create topic TEST-TOPIC-GRPC-ASYNC on rocketmq-console
- start publisher to publish to the topic as the following:

```
Run the main method of org.apache.eventmesh.grpc.pub.eventmeshmessage.BatchPublishInstance
```
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static void main(String[] args) throws Exception {
final String eventMeshIp = properties.getProperty("eventmesh.ip");
final String eventMeshGrpcPort = properties.getProperty("eventmesh.grpc.port");

final String topic = "TEST-TOPIC-GRPC-RR";
final String topic = "TEST-TOPIC-GRPC-ASYNC";

EventMeshGrpcClientConfig eventMeshClientConfig = EventMeshGrpcClientConfig.builder()
.serverAddr(eventMeshIp)
Expand Down

0 comments on commit 96306f7

Please sign in to comment.