Skip to content

Commit

Permalink
Merge branch 'apache:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
RiemannChow authored Sep 6, 2022
2 parents 6551479 + 3aae182 commit c168cfd
Show file tree
Hide file tree
Showing 49 changed files with 1,243 additions and 156 deletions.
1 change: 1 addition & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ header:
- '**/*.crt'
- '**/*.pem'
- '**/go.sum'
- '**/Cargo.lock'
- 'LICENSE'
- 'NOTICE'
- 'DISCLAIMER-WIP'
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ subprojects {
dependency "com.fasterxml.jackson.core:jackson-core:2.13.0"
dependency "com.fasterxml.jackson.core:jackson-annotations:2.13.0"

dependency "org.asynchttpclient:async-http-client:2.12.0"
dependency "org.apache.httpcomponents:httpclient:4.5.13"

dependency "io.netty:netty-all:4.1.73.Final"
Expand Down
91 changes: 91 additions & 0 deletions docs/en/connector-knative/01-eventmesh-connector-knative.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# EventMesh-Knative插件

## 准备
### 创建Knative Source和Sink
我们使用 *cloudevents-player* [Knative服务](https://knative.dev/docs/serving/)作为例子。如果您不知道如何创建 *cloudevents-player* Knative服务作为source和sink,请按照这个[链接](https://knative.dev/docs/getting-started/first-source/#creating-your-first-source)的步骤进行创建。

### EventMesh配置文件
- 将以下配置加入 [eventmesh-starter/build.gradle](https://github.com/apache/incubator-eventmesh/blob/master/eventmesh-starter/build.gradle) 文件
```bash
plugins {
id 'application'
}

application {
mainClass = project.hasProperty("mainClass") ? project.getProperty("mainClass") : 'org.apache.eventmesh.starter.StartUp'
applicationDefaultJvmArgs = [
'-Dlog4j.configurationFile=../eventmesh-runtime/conf/log4j2.xml', '-Deventmesh.log.home=../eventmesh-runtime/logs', '-Deventmesh.home=../eventmesh-runtime', '-DconfPath=../eventmesh-runtime/conf'
]
}

dependencies {
implementation project(":eventmesh-connector-plugin:eventmesh-connector-knative")
implementation project(":eventmesh-runtime")
}
```
- 将以下配置加入 [eventmesh-examples/build.gradle](https://github.com/apache/incubator-eventmesh/blob/master/eventmesh-examples/build.gradle)文件
```bash
plugins {
id 'application'
}

application {
mainClass = project.hasProperty("mainClass") ? project.getProperty("mainClass") : 'NULL'
}
```
-[eventmesh-runtime/conf/eventmesh.properties](https://github.com/pchengma/incubator-eventmesh/blob/master/eventmesh-runtime/conf/eventmesh.properties) 文件中设置```eventMesh.connector.plugin.type=knative```变量

## 演示
### Knative发布事件消息/EventMesh订阅
#### 步骤1:启动一台EventMesh服务器
```bash
$ cd eventmesh-starter
$ ../gradlew -PmainClass=org.apache.eventmesh.starter.StartUp run
```

#### 步骤2:从Knative Source发布一条消息
```bash
$ curl -i http://cloudevents-player.default.127.0.0.1.sslip.io -H "Content-Type: application/json" -H "Ce-Id: 123456789" -H "Ce-Specversion: 1.0" -H "Ce-Type: some-type" -H "Ce-Source: command-line" -d '{"msg":"Hello CloudEvents!"}'
```

#### 步骤3:从EventMesh订阅
-[ExampleConstants.java](https://github.com/apache/incubator-eventmesh/blob/master/eventmesh-examples/src/main/java/org/apache/eventmesh/common/ExampleConstants.java) 文件中设置 ```public static final String EVENTMESH_HTTP_ASYNC_TEST_TOPIC = "messages";```变量
```bash
$ cd eventmesh-examples
$ ../gradlew -PmainClass=org.apache.eventmesh.http.demo.sub.SpringBootDemoApplication run
```
#### 预期结果
以下```data``````Hello CloudEvents!```的消息将会打印在EventMesh服务器的控制台上。
```bash
2022-09-05 16:37:58,237 INFO [eventMesh-clientManage-] DefaultConsumer(DefaultConsumer.java:60) - \
[{"event":{"attributes":{"datacontenttype":"application/json","id":"123456789","mediaType":"application/json",\
"source":"command-line","specversion":"1.0","type":"some-type"},"data":{"msg":"Hello CloudEvents!"},"extensions":{}},\
"id":"123456789","receivedAt":"2022-09-05T10:37:49.537658+02:00[Europe/Madrid]","type":"RECEIVED"}]
```

### EventMessh发布事件消息/Knative订阅
#### 步骤1:启动一台EventMesh服务器
```bash
$ cd eventmesh-starter
$ ../gradlew -PmainClass=org.apache.eventmesh.starter.StartUp run
```

#### 步骤2:从EventMesh发布一条消息
我们用Knative Connector的测试程序来演示这个功能。
```bash
$ cd eventmesh-connector-plugin/eventmesh-connector-knative
$ ../../gradlew clean test --tests KnativeProducerImplTest.testPublish
```

#### 步骤3:从Knative订阅
```bash
$ curl http://cloudevents-player.default.127.0.0.1.sslip.io/messages
```

#### 预期结果
以下```data``````Hello Knative from EventMesh!```的消息将会打印在EventMesh服务器的控制台上。
```bash
2022-09-05 16:52:41,633 INFO [eventMesh-clientManage-] DefaultConsumer(DefaultConsumer.java:60) - \
[{"event":{"attributes":{"datacontenttype":"application/json","id":"1234","mediaType":"application/json",\
"source":"java-client","specversion":"1.0","type":"some-type"},"data":{"msg":["Hello Knative from EventMesh!"]},"extensions":{}},"id":"1234","receivedAt":"2022-09-05T10:52:32.999273+02:00[Europe/Madrid]","type":"RECEIVED"}]
```
4 changes: 4 additions & 0 deletions docs/en/connector-knative/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "EventMesh Connector Knative",
"collapsed": false
}
93 changes: 93 additions & 0 deletions docs/zh/connector-knative/01-eventmesh-connector-knative.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Eventmesh-Connector-Knative

## Prerequisite
### Create Knative Source and Sink
We use the *cloudevents-player* [Knative service](https://knative.dev/docs/serving/) as an example. If you do not know how to create *cloudevents-player* Knative service as source and sink, please follow the steps in this [link](https://knative.dev/docs/getting-started/first-source/#creating-your-first-source).


### Set up EventMesh Configuration
- Add the following lines to [eventmesh-starter/build.gradle](https://github.com/apache/incubator-eventmesh/blob/master/eventmesh-starter/build.gradle) file.
```
plugins {
id 'application'
}
application {
mainClass = project.hasProperty("mainClass") ? project.getProperty("mainClass") : 'org.apache.eventmesh.starter.StartUp'
applicationDefaultJvmArgs = [
'-Dlog4j.configurationFile=../eventmesh-runtime/conf/log4j2.xml', '-Deventmesh.log.home=../eventmesh-runtime/logs', '-Deventmesh.home=../eventmesh-runtime', '-DconfPath=../eventmesh-runtime/conf'
]
}
dependencies {
implementation project(":eventmesh-connector-plugin:eventmesh-connector-knative")
implementation project(":eventmesh-runtime")
}
```
- Add the following lines to [eventmesh-examples/build.gradle](https://github.com/apache/incubator-eventmesh/blob/master/eventmesh-examples/build.gradle) file.
```
plugins {
id 'application'
}
application {
mainClass = project.hasProperty("mainClass") ? project.getProperty("mainClass") : 'NULL'
}
```
- Set ```eventMesh.connector.plugin.type=knative``` in [eventmesh-runtime/conf/eventmesh.properties](https://github.com/pchengma/incubator-eventmesh/blob/master/eventmesh-runtime/conf/eventmesh.properties) file.

## Demo
### Publish an Event Message from Knative and Subscribe from EventMesh
#### Step 1: Start an Eventmesh-Runtime Server
```bash
$ cd eventmesh-starter
$ ../gradlew -PmainClass=org.apache.eventmesh.starter.StartUp run
```

#### Step 2: Publish an Event Message from Knative
```bash
$ curl -i http://cloudevents-player.default.127.0.0.1.sslip.io -H "Content-Type: application/json" -H "Ce-Id: 123456789" -H "Ce-Specversion: 1.0" -H "Ce-Type: some-type" -H "Ce-Source: command-line" -d '{"msg":"Hello CloudEvents!"}'
```

#### Step 3: Subscribe from an EventMesh
- Set ```public static final String EVENTMESH_HTTP_ASYNC_TEST_TOPIC = "messages";``` in [ExampleConstants.java](https://github.com/apache/incubator-eventmesh/blob/master/eventmesh-examples/src/main/java/org/apache/eventmesh/common/ExampleConstants.java) file.
```bash
$ cd eventmesh-examples
$ ../gradlew -PmainClass=org.apache.eventmesh.http.demo.sub.SpringBootDemoApplication run
```

#### Expected Result
The following message with ```data``` field as ```Hello CloudEvents!``` will be printed on the console of EventMesh server.
```bash
2022-09-05 16:37:58,237 INFO [eventMesh-clientManage-] DefaultConsumer(DefaultConsumer.java:60) - \
[{"event":{"attributes":{"datacontenttype":"application/json","id":"123456789","mediaType":"application/json",\
"source":"command-line","specversion":"1.0","type":"some-type"},"data":{"msg":"Hello CloudEvents!"},"extensions":{}},\
"id":"123456789","receivedAt":"2022-09-05T10:37:49.537658+02:00[Europe/Madrid]","type":"RECEIVED"}]
```

### Publish an Event Message from EventMesh and Subscribe from Knative
#### Step 1: Start an Eventmesh-Runtime Server
```bash
$ cd eventmesh-starter
$ ../gradlew -PmainClass=org.apache.eventmesh.starter.StartUp run
```

#### Step 2: Publish an Event Message from EventMesh
We use a test program to demo this function.
```bash
$ cd eventmesh-connector-plugin/eventmesh-connector-knative
$ ../../gradlew clean test --tests KnativeProducerImplTest.testPublish
```

#### Step 3: Subscribe from Knative
```bash
$ curl http://cloudevents-player.default.127.0.0.1.sslip.io/messages
```

#### Expected Result
The following message with ```data``` field as ```Hello Knative from EventMesh!``` will be printed on the console of EventMesh server.
```bash
2022-09-05 16:52:41,633 INFO [eventMesh-clientManage-] DefaultConsumer(DefaultConsumer.java:60) - \
[{"event":{"attributes":{"datacontenttype":"application/json","id":"1234","mediaType":"application/json",\
"source":"java-client","specversion":"1.0","type":"some-type"},"data":{"msg":["Hello Knative from EventMesh!"]},"extensions":{}},"id":"1234","receivedAt":"2022-09-05T10:52:32.999273+02:00[Europe/Madrid]","type":"RECEIVED"}]
```
5 changes: 5 additions & 0 deletions docs/zh/connector-knative/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"position": 7,
"label": "EventMesh Connector Knative",
"collapsed": false
}
20 changes: 10 additions & 10 deletions docs/zh/desing-document/webhook.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ eventMesh.webHook.producer.connector=standalone
#### 第二步:添加webhook配置信息
配置信息说明
```java
/**
* 厂商调用的path。厂商事件调用地址、 [http or https ]://[域名 or IP 【厂商可以被调用】]:[端口]/webhook/[callbackPath]
* 比如:http://127.0.0.1:10504/webhook/test/event 需要把全完url填入厂商调用输入中
* callbackPath 是唯一
* manufacturer callback path
*/
/**
* 厂商调用的path。厂商事件调用地址、 [http or https ]://[域名 or IP 【厂商可以被调用】]:[端口]/webhook/[callbackPath]
* 比如:http://127.0.0.1:10504/webhook/test/event 需要把全完url填入厂商调用输入中
* callbackPath 是唯一
* manufacturer callback path
*/
private String callbackPath;

/**
Expand Down Expand Up @@ -251,13 +251,13 @@ contentType: application/json
### github 注册
#### 第一步:进入对应的项目
#### 第二步:点击setting
![](../images/features/webhook/webhook-github-setting.png)
![](../../images/design-document/webhook/webhook-github-setting.png)
#### 第三步:点击Webhooks
![](../images/features/webhook/webhook-github-webhooks.png)
![](../../images/design-document/webhook/webhook-github-webhooks.png)
#### 第四步:点击 Add webhook
![](../images/features/webhook/webhook-github-add.png)
![](../../images/design-document/webhook/webhook-github-add.png)
#### 第五步: 填写webhook信息
![](../images/features/webhook/webhook-github-info.png)
![](../../images/design-document/webhook/webhook-github-info.png)

Payload URL: 服务地址以及pahts。[http or https ]://[域名 or IP 【厂商可以被调用】]:[端口]/webhook/[callbackPath]
Content type:http header content type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,4 @@ public class Constants {
public static final String AND = "&";

public static final String EMPTY = "";

/**
* GRPC PROTOCOL
*/
public static final String PROTOCOL_GRPC = "grpc";

/**
* application/cloudevents+json Content-type
*/
public static final String CONTENT_TYPE_CLOUDEVENTS_JSON = "application/cloudevents+json";
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public static CloudEvent generateCloudEventV1Async() {
.withId(UUID.randomUUID().toString())
.withSubject(ExampleConstants.EVENTMESH_TCP_ASYNC_TEST_TOPIC)
.withSource(URI.create("/"))
.withDataContentType(ExampleConstants.CLOUDEVENT_CONTENT_TYPE)
.withDataContentType("application/cloudevents+json")
.withType(EventMeshCommon.CLOUD_EVENTS_PROTOCOL_NAME)
.withData(JsonUtils.serialize(content).getBytes(StandardCharsets.UTF_8))
.withExtension("ttl", "30000")
Expand Down
Loading

0 comments on commit c168cfd

Please sign in to comment.