diff --git a/.asf.yaml b/.asf.yaml
index 66dc6d7649..63fe6434db 100644
--- a/.asf.yaml
+++ b/.asf.yaml
@@ -37,8 +37,8 @@ github:
- microservice
- state-management
enabled_merge_buttons:
+ merge: true
squash: true
- merge: false
rebase: false
protected_branches:
master:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index f2b0aa255b..b302599843 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -33,48 +33,32 @@ on:
jobs:
build:
name: Build
-
- runs-on: ubuntu-latest
-
strategy:
fail-fast: false
matrix:
- language:
- - 'java'
- java:
- - 8
+ os: [ubuntu-latest, macOS-latest]
+ java: [8, 11]
+ runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- - name: Initialize CodeQL
- uses: github/codeql-action/init@v1
- with:
- # If you wish to specify custom queries, you can do so here or in a config file.
- # By default, queries listed here will override any specified in a config file.
- # Prefix the list here with "+" to use these queries and those in the config file.
- # queries: ./path/to/local/query, your-org/your-repo/queries@main
- languages: ${{ matrix.language }}
-
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: Build
- # skip check here, since we use Checkstyle task to check the added file
- run: ./gradlew clean build jacocoTestReport checkLicense -x check
+ # We use -x check to skip check code style here, since this task will check all files.
+ # We use Checkstyle task to check the added file
+ run: ./gradlew clean build jar dist jacocoTestReport -x check
- - name: Perform CodeQL analysis
- uses: github/codeql-action/analyze@v1
-
- - name: Upload coverage report to codecov.io
- run: bash <(curl -s https://codecov.io/bash) || echo 'Failed to upload coverage report!'
+ - name: Install plugin
+ run: ./gradlew installPlugin
checkstyle:
name: Checkstyle
-
runs-on: ubuntu-latest
steps:
@@ -96,7 +80,6 @@ jobs:
license-check:
name: License Check
-
runs-on: ubuntu-latest
steps:
@@ -104,6 +87,9 @@ jobs:
uses: actions/checkout@v2
- name: Check license header
- uses: apache/skywalking-eyes@9bd5feb86b5817aa6072b008f9866a2c3bbc8587
+ uses: apache/skywalking-eyes@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Check third party dependencies
+ run: ./gradlew clean jar dist && ./gradlew installPlugin && ./gradlew tar && sh tools/third-party-dependencies/check-dependencies.sh && echo "Thirty party dependencies check success"
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 922026cd64..edb1b1809e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,4 +20,11 @@ classes
package-lock.json
node_modules
.DS_Store
-.run
\ No newline at end of file
+.run
+
+h2/db.mv.db
+
+# license check tmp file
+all-dependencies.txt
+self-modules.txt
+third-party-dependencies.txt
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 16b6b6602d..8c34df7a77 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -37,15 +37,15 @@ Here are the workflow for contributors:
1. Fork to your own
2. Clone fork to local repository
-```shell
+```git
git clone git@github.com:yourgithub/incubator-eventmesh.git
```
3. Create a new branch and work on it
-```shell
+```git
git checkout -b fix_patch_xx
```
4. Keep your branch in sync
-```shell
+```git
git remote add upstream git@github.com:apache/incubator-eventmesh.git
git fetch upstream develop:upstream_develop
git rebase upstream_develop
@@ -65,18 +65,20 @@ EventMesh repository, and the related Issue will be closed.
We use [GitHub Issues](https://github.com/apache/incubator-eventmesh/issues)
and [Pull Requests](https://github.com/apache/incubator-eventmesh/pulls) for trackers.
-If you find a typo in a document, find a bug in code, or want new features, or want to give suggestions, you
+If you find a bug in code, or want new features, or want to give suggestions, you
can [open an issue on GitHub](https://github.com/apache/incubator-eventmesh/issues/new) to report it. Please follow the
guideline message in the issue template.
-If you want to contribute, please follow the [contribution workflow](#github-workflow) and create a new pull request. If
-your PR contains large changes, e.g. component refactor or new components, please write detailed documents about its
+If you want to contribute, please follow the [contribution workflow](#github-workflow) and create a new pull request. Your PR title should start with [ISSUE #xx].
+If your PR contains large changes, e.g. component refactor or new components, please write detailed documents about its
design and usage.
-Note that a single pull request should not be too large. If heavy changes are required, it's better to separate the
+If your change is about a typo or small optimize, you needn't create an Issue, just submit a PR and title with [MINOR].
+
+[Note]: A single pull request should not be too large. If heavy changes are required, it's better to separate the
changes to a few individual PRs.
-### Code review
+### PR review
All code should be well reviewed by one or more committers. Some principles:
@@ -88,11 +90,18 @@ All code should be well reviewed by one or more committers. Some principles:
EventMesh follows [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) policy. All source files should
have the Apache License header added to the file header. EventMesh uses the [apache/skywalking-eyes](https://github.com/apache/skywalking-eyes) to check
-the source file header, and EventMesh uses [Gradle-License-Report](https://github.com/jk1/Gradle-License-Report) plugin to check for third-part dependencies.
-When you need to add a three-part dependency, you need to register the newly added dependency in tool/license/allowed-licenses.txt, you can execute `./gradlew clean checkLicense` to judge
-whether there exist dependencies have been added, and the newly added three-part libraries need to meet [ASF 3RD PARTY LICENSE POLICY](https://apache.org/legal/resolved.html).
+the source file header.
+
+EventMesh uses [check-dependencies.sh](tools/third-party-dependencies/check-dependencies.sh) script to check for third-part dependencies.
+When you need to add a three-part dependency, you need to register the newly added dependency in tool/license/known-dependencies.txt. The newly added three-part libraries need to meet [ASF 3RD PARTY LICENSE POLICY](https://apache.org/legal/resolved.html).
It is highly recommended communicating with EventMesh community before you need to add a three-part library.
+### PR merge
+
+After a PR is approved by at least one committer, it can be merged. Before the merge, the committer can make changes to the commits message, requiring the commits
+message to be clear without duplication, and use Squash and Merge to make sure one PR should only contain one commits.
+For large multi-person PR, use Merge to merge, and fix the commits by rebase before merging.
+
## Community
### Contact us
diff --git a/CONTRIBUTING.zh-CN.md b/CONTRIBUTING.zh-CN.md
index 0fede22ee3..dd6bc64a3a 100644
--- a/CONTRIBUTING.zh-CN.md
+++ b/CONTRIBUTING.zh-CN.md
@@ -31,15 +31,15 @@ Editor -> Code Style -> Java -> Scheme -> Import Scheme -> CheckStyle Configurat
1. Fork到您个人仓库
2. 克隆到本地存储库
-```shell
+```git
git clone git@github.com:yourgithub/incubator-eventmesh.git
```
3. 创建一个新分支并对其进行处理
-```shell
+```git
git checkout -b fix_patch_xx
```
4. 保持分支与主库同步
-```shell
+```git
git remote add upstream git@github.com:apache/incubator-eventmesh.git
git fetch upstream develop:upstream_develop
git rebase upstream_develop
@@ -56,19 +56,20 @@ git rebase upstream_develop
### 打开问题/ PR
我们将使用Issues和Pull Requests作为跟踪器
-[GitHub Issues](https://github.com/apache/incubator-eventmesh/issues)
-[Pull Requests](https://github.com/apache/incubator-eventmesh/pulls)
+- [GitHub Issues](https://github.com/apache/incubator-eventmesh/issues)
+- [Pull Requests](https://github.com/apache/incubator-eventmesh/pulls)
-如果您在文档中发现拼写错误,在代码中发现错误,想要新功能或提出建议, 您可以提出问题[在GitHub上打开问题](https://github.com/apache/incubator-eventmesh/issues/new)
-请按照问题模板中的准则消息进行操作。
+如果您发现新的Bug,想要新功能或提出新当建议,您可以在GitHub上[创建Issue](https://github.com/apache/incubator-eventmesh/issues/new) ,请按照Issue模板中的准则进行操作。
+如果您在文档中发现拼写错误,或者发现代码中存在可以进行微小的优化的地方,您可以无需创建Issue, 直接提交一个PR。
如果您想贡献,请遵循[贡献工作流程](#github-workflow)并创建一个新的拉取请求。 如果您的PR包含较大的更改,例如组件重构或新组件,请写详细文档 有关其设计和使用的信息。
+对于PR的标题请依照[ISSUE #xx]进行开头,如果是细小的改动请以[MINOR]进行开头。
-请注意,单个拉取请求不应太大。如果需要进行重大更改,最好将更改分开 到一些个人PR。
+【注意】: 单个PR不应太大。如果需要进行重大更改,最好将更改分开 到一些个人PR。
-### 代码审查
+### PR审查
-所有代码应由一个或多个committer进行良好的审查。一些原则:
+所有PR应由一个或多个committer进行良好的审查。一些原则:
- 可读性: 重要代码应有详细记录。符合我们的[代码风格](./style/checkStyle.xml)
- 优雅: 新功能,类或组件应经过精心设计
@@ -78,10 +79,18 @@ git rebase upstream_develop
EventMesh遵循[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) 政策。
所有的源代码文件应该在文件头部添加Apache License header,EventMesh会使用[apache/skywalking-eyes](https://github.com/apache/skywalking-eyes)
-对源代码文件头进行校验。EventMesh使用[Gradle-License-Report](https://github.com/jk1/Gradle-License-Report)插件
-检查第三方依赖,当你需要添加三方依赖时,你需要将新添加的依赖注册在tool/license/allowed-licenses.txt中,你可以通过执行`./gradlew clean checkLicense`命令可以判断当前是否有license尚未添加,
+对源代码文件头进行校验。
+
+EventMesh使用[check-dependencies.sh](tools/third-party-dependencies/check-dependencies.sh)脚本
+检查第三方依赖,当你需要添加三方依赖时,你需要将新添加的依赖注册在tool/license/known-dependencies.txt中,
同时新添加的三方库需要满足[Apache对于第三方的政策](https://apache.org/legal/resolved.html)。
-非常建议在需要添加三方依赖之前与EventMesh社区进行沟通。
+
+当添加依赖时遇到问题时,社区PPMC会协助解决,非常建议在需要添加三方依赖之前与EventMesh社区进行沟通。
+
+### PR合并
+
+PR经过至少一个committer approve之后会由committer负责合并,在合并的时候,committer可以对commits信息进行修改,要求commits信息简洁明了,不重复。
+在合并时使用Squash and merge, 要求一个PR保留一个commits。对于大型多人协助的PR,使用Merge进行合并,在合并之前通过rebase修正commits。
## 社区
diff --git a/README.md b/README.md
index 94c3742db3..9e27b02873 100644
--- a/README.md
+++ b/README.md
@@ -1,144 +1,143 @@
-# Apache EventMesh (incubating)
-[![CI status](https://github.com/apache/incubator-eventmesh/actions/workflows/ci.yml/badge.svg)](https://github.com/apache/incubator-eventmesh/actions/workflows/ci.yml)
-[![CodeCov](https://codecov.io/gh/apache/incubator-eventmesh/branch/develop/graph/badge.svg)](https://codecov.io/gh/apache/incubator-eventmesh)
-[![Language grade: Java](https://img.shields.io/lgtm/grade/java/g/apache/incubator-eventmesh.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/apache/incubator-eventmesh/context:java)
-[![Total alerts](https://img.shields.io/lgtm/alerts/g/apache/incubator-eventmesh.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/apache/incubator-eventmesh/alerts/)
-[![GitHub release](https://img.shields.io/badge/release-download-orange.svg)](https://github.com/apache/incubator-eventmesh/releases)
-[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
-
-[点我查看中文版](README.zh-CN.md)
-
-![logo](docs/images/logo2.png)
-## What is EventMesh?
-EventMesh(incubating) is a dynamic event-driven application runtime used to decouple the application and backend middleware layer, which supports a wide range of use cases that encompass complex multi-cloud, widely distributed topologies using diverse technology stacks.
-
-![architecture1](docs/images/eventmesh-multi-runtime.png)
-
-**EventMesh Architecture:**
-
-![architecture1](docs/images/eventmesh-runtime2.png)
-
-**Components:**
-
-* **eventmesh-runtime** : an middleware to transmit events between event producers and consumers, support cloud native apps and microservices.
-* **eventmesh-sdk-java** : currently supports HTTP and TCP protocols.
-* **eventmesh-connector-api** : an api layer based on OpenMessaging api and SPI pluggin, which can be implemented by popular EventStores such as IMDG, Messaging Engine and OSS etc.
-* **eventmesh-connector-plugin** : plugins for connector.
-* **eventmesh-connector-standalone** : an implementation of eventmesh-connector-api, pub event to or sub event from InMemory as EventStore.
-* **eventmesh-connector-rocketmq** : an implementation of eventmesh-connector-api, pub event to or sub event from RocketMQ as EventStore.
-* **eventmesh-connector-kafka(WIP)** : an implementation of eventmesh-connector-api, pub event to or sub event from Kafka as EventStore.
-* **eventmesh-connector-redis(WIP)** : an implementation of eventmesh-connector-api, pub event to or sub event from Redis as EventStore.
-* **eventmesh-connector-defibus(WIP)** : an implementation of eventmesh-connector-api, pub event to or sub event from [DeFiBus](https://github.com/webankfintech/defibus) as EventStore
-* **eventmesh-admin** : clients,topics,subscriptions and other management.
-* **eventmesh-registry-plugin** : plugins for registry adapter.
-* **eventmesh-security-plugin** : plugins for security adpater.
-* **eventmesh-protocol-plugin** : plugins for protocol adapter.
-
-**Protocol:**
-
-The protocol of eventmesh is easier and more convenient, you can read more [here](docs/en/instructions/eventmesh-runtime-protocol.md)
-
-## Feature
-
-Event & Service
-- [x] Pub/Sub
-- [x] Request/Reply
-- [ ] Event Streaming
-- [ ] Event transaction
-- [ ] At-least-once/at-most-once delivery guarantees
-
-Connector
-- [x] RocketMQ
-- [x] InMemory
-- [ ] Federated
-- [ ] Kafka
-- [ ] Redis
-- [ ] Pulsar
-- [ ] RabbitMQ
-- [ ] DeFiBus
-- [ ] Cold storage (S3, Minio, SQL, key/value, etc...)
-
-Protocol
-- [x] TCP
-- [x] Http
-- [ ] gRPC
-- [ ] CloudEvents
-- [ ] MQTT
-- [ ] AsyncAPI
-
-SDK
-- [x] Java
-- [ ] C
-- [ ] Go
-- [ ] Python
-
-Deploy
-- [x] Sidecar
-- [x] Gateway
-- [x] Docker
-
-Metrics
-- [x] OpenTelemetry
-- [x] Promethus exporter
-
-Tracing
-- [x] OpenTelemetry
-- [x] Zipkin exporter
-- [ ] Skywalking
-
-Governance
-- [x] Client management
-- [ ] Topic management
-- [ ] Metadata registry
-- [x] Schema registry
-- [ ] Dynamic config
-
-Choreography
-- [ ] Servelss workflow
-- [ ] Event function,triggers and bindings
-
-Security
-- [ ] Auth
-- [ ] ACL
-
-Runtime
-- [ ] WebAssembly runtime
-
-## Quick Start
-1. [Connector quickstart](https://rocketmq.apache.org/docs/quick-start/) (RocketMQ, ignore this step if use standalone).
-2. [Runtime quickstart](docs/en/instructions/eventmesh-runtime-quickstart.md) or [Runtime quickstart with docker](docs/en/instructions/eventmesh-runtime-quickstart-with-docker.md).
-3. [Java SDK examples](docs/en/instructions/eventmesh-sdk-java-quickstart.md).
-
-## Contributing
-Contributions are always welcomed! Please see [CONTRIBUTING](CONTRIBUTING.md) for detailed guidelines.
-
-You can start with the issues labeled with good first issue.
-[GitHub Issues](https://github.com/apache/incubator-eventmesh/issues)
-
-## Landscape
-
-
-
-
-EventMesh enriches the CNCF CLOUD NATIVE Landscape.
-
-
-## License
-[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) Copyright (C) Apache Software Foundation.
-
-## Community
-| WeChat group | WeChat public account |
-| :---------------------------------------: | :----------------------------------------------------: |
-| ![wechat_qr](docs/images/mesh-helper.jpg) | ![wechat_official_qr](docs/images/wechat-official.png) |
-
-
-
-
-
-Mailing Lists:
-
-| Name | Description |Subscribe |Unsubscribe|Archive
-| ---- | ---- |---- | ---- | ---- |
-|Users |User support and questions mailing list| [Subscribe](mailto:users-subscribe@eventmesh.incubator.apache.org) |[Unsubscribe](mailto:users-unsubscribe@eventmesh.incubator.apache.org) |[Mail Archives](https://lists.apache.org/list.html?users@eventmesh.apache.org)|
-|Development |Development related discussions| [Subscribe](mailto:dev-subscribe@eventmesh.incubator.apache.org) |[Unsubscribe](mailto:dev-unsubscribe@eventmesh.incubator.apache.org) |[Mail Archives](https://lists.apache.org/list.html?dev@eventmesh.apache.org)|
-|Commits |All commits to repositories| [Subscribe](mailto:commits-subscribe@eventmesh.incubator.apache.org) |[Unsubscribe](mailto:commits-unsubscribe@eventmesh.incubator.apache.org) |[Mail Archives](https://lists.apache.org/list.html?commits@eventmesh.apache.org)|
+# Apache EventMesh (incubating)
+[![CI status](https://github.com/apache/incubator-eventmesh/actions/workflows/ci.yml/badge.svg)](https://github.com/apache/incubator-eventmesh/actions/workflows/ci.yml)
+[![CodeCov](https://codecov.io/gh/apache/incubator-eventmesh/branch/develop/graph/badge.svg)](https://codecov.io/gh/apache/incubator-eventmesh)
+[![Language grade: Java](https://img.shields.io/lgtm/grade/java/g/apache/incubator-eventmesh.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/apache/incubator-eventmesh/context:java)
+[![Total alerts](https://img.shields.io/lgtm/alerts/g/apache/incubator-eventmesh.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/apache/incubator-eventmesh/alerts/)
+[![GitHub release](https://img.shields.io/badge/release-download-orange.svg)](https://github.com/apache/incubator-eventmesh/releases)
+[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
+[![Slack Status](https://img.shields.io/badge/slack-join_chat-white.svg?logo=slack&style=social)](https://join.slack.com/t/apacheeventmesh/shared_invite/zt-yx3n2ak7-HcVG98CDqb~7PwgoDzgfMA)
+
+[点我查看中文版](README.zh-CN.md)
+
+![logo](docs/images/logo2.png)
+## What is EventMesh?
+EventMesh(incubating) is a dynamic event-driven application runtime used to decouple the application and backend middleware layer, which supports a wide range of use cases that encompass complex multi-cloud, widely distributed topologies using diverse technology stacks.
+
+![architecture1](docs/images/eventmesh-multi-runtime.png)
+
+**EventMesh Architecture:**
+
+![architecture1](docs/images/eventmesh-runtime2.png)
+
+**Components:**
+
+* **eventmesh-runtime** : an middleware to transmit events between event producers and consumers, support cloud native apps and microservices.
+* **eventmesh-sdk-java** : currently supports HTTP and TCP protocols.
+* **eventmesh-connector-api** : an api layer based on OpenMessaging api and SPI pluggin, which can be implemented by popular EventStores such as IMDG, Messaging Engine and OSS etc.
+* **eventmesh-connector-plugin** : plugins for connector.
+* **eventmesh-connector-standalone** : an implementation of eventmesh-connector-api, pub event to or sub event from InMemory as EventStore.
+* **eventmesh-connector-rocketmq** : an implementation of eventmesh-connector-api, pub event to or sub event from RocketMQ as EventStore.
+* **eventmesh-connector-kafka(WIP)** : an implementation of eventmesh-connector-api, pub event to or sub event from Kafka as EventStore.
+* **eventmesh-connector-redis(WIP)** : an implementation of eventmesh-connector-api, pub event to or sub event from Redis as EventStore.
+* **eventmesh-connector-defibus(WIP)** : an implementation of eventmesh-connector-api, pub event to or sub event from [DeFiBus](https://github.com/webankfintech/defibus) as EventStore
+* **eventmesh-admin** : clients,topics,subscriptions and other management.
+* **eventmesh-registry-plugin** : plugins for registry adapter.
+* **eventmesh-security-plugin** : plugins for security adpater.
+* **eventmesh-protocol-plugin** : plugins for protocol adapter.
+
+**Protocol:**
+
+The protocol of eventmesh is easier and more convenient, you can read more [here](docs/en/instructions/eventmesh-runtime-protocol.md)
+
+## Feature
+
+Event & Service
+- [x] Pub/Sub
+- [x] Request/Reply
+- [ ] Event Streaming
+- [ ] Event transaction
+- [ ] At-least-once/at-most-once delivery guarantees
+
+Store Connector
+- [x] RocketMQ
+- [x] InMemory
+- [ ] Federated
+- [ ] Kafka
+- [ ] Redis
+- [ ] Pulsar
+- [ ] RabbitMQ
+- [ ] DeFiBus
+- [ ] Cold storage (S3, Minio, SQL, key/value, etc...)
+
+Protocol
+- [x] TCP
+- [x] Http
+- [ ] gRPC
+- [ ] CloudEvents
+- [ ] MQTT
+- [ ] WebSocket
+- [ ] AMQP
+- [ ] AsyncAPI
+
+SDK
+- [x] Java
+- [ ] C
+- [ ] Go
+- [ ] Python
+
+Deploy
+- [x] Sidecar
+- [x] Gateway
+- [x] Docker
+
+Metrics
+- [x] OpenTelemetry
+- [x] Promethus exporter
+
+Tracing
+- [x] OpenTelemetry
+- [x] Zipkin exporter
+- [ ] Skywalking
+
+Governance
+- [x] Client management
+- [ ] Topic management
+- [ ] Metadata registry
+- [ ] Schema registry
+- [ ] Dynamic config
+
+Choreography
+- [ ] Servelss workflow
+- [ ] Event function,triggers and bindings
+
+Security
+- [ ] Auth
+- [ ] ACL
+
+Runtime
+- [ ] WebAssembly runtime
+
+## Quick Start
+1. [Store quickstart](docs/en/instructions/eventmesh-store-quickstart.md)
+2. [Runtime quickstart](docs/en/instructions/eventmesh-runtime-quickstart.md) or [Runtime quickstart with docker](docs/en/instructions/eventmesh-runtime-quickstart-with-docker.md).
+3. [Java SDK examples](docs/en/instructions/eventmesh-sdk-java-quickstart.md).
+
+## Contributing
+Contributions are always welcomed! Please see [CONTRIBUTING](CONTRIBUTING.md) for detailed guidelines.
+
+You can start with the issues labeled with good first issue.
+[GitHub Issues](https://github.com/apache/incubator-eventmesh/issues)
+
+## Landscape
+
+
+
+
+EventMesh enriches the CNCF CLOUD NATIVE Landscape.
+
+
+## License
+[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) Copyright (C) Apache Software Foundation.
+
+## Community
+| WeChat Assistant | WeChat public account | Slack |
+| :----------------------------------------------------: | :----------------------------------------------------: | :----------------------------------------------------: |
+| ![wechat_qr](docs/images/mesh-helper.jpg) | ![wechat_official_qr](docs/images/wechat-official.png) |[Join slack chat](https://join.slack.com/t/apacheeventmesh/shared_invite/zt-yx3n2ak7-HcVG98CDqb~7PwgoDzgfMA) |
+
+Mailing Lists:
+
+| Name | Description |Subscribe |Unsubscribe|Archive
+| ---- | ---- |---- | ---- | ---- |
+|Users |User support and questions mailing list| [Subscribe](mailto:users-subscribe@eventmesh.incubator.apache.org) |[Unsubscribe](mailto:users-unsubscribe@eventmesh.incubator.apache.org) |[Mail Archives](https://lists.apache.org/list.html?users@eventmesh.apache.org)|
+|Development |Development related discussions| [Subscribe](mailto:dev-subscribe@eventmesh.incubator.apache.org) |[Unsubscribe](mailto:dev-unsubscribe@eventmesh.incubator.apache.org) |[Mail Archives](https://lists.apache.org/list.html?dev@eventmesh.apache.org)|
+|Commits |All commits to repositories| [Subscribe](mailto:commits-subscribe@eventmesh.incubator.apache.org) |[Unsubscribe](mailto:commits-unsubscribe@eventmesh.incubator.apache.org) |[Mail Archives](https://lists.apache.org/list.html?commits@eventmesh.apache.org)|
diff --git a/README.zh-CN.md b/README.zh-CN.md
index bea441be47..08ebe7c924 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -36,7 +36,7 @@ EventMesh是一个动态的云原生事件驱动架构基础设施,用于分
**通信协议:**
-eventmesh的通信协议更加简洁方便,详细内容,阅读更多[这里](docs/cn/instructions/eventmesh-runtime-protocol.zh-CN.md)
+eventmesh的通信协议更加简洁方便,详细内容,阅读更多[这里](docs/cn/instructions/eventmesh-runtime-protocol.md)
## RoadMap
| version | feature |
diff --git a/build.gradle b/build.gradle
index aa6074c715..9dc04941b8 100644
--- a/build.gradle
+++ b/build.gradle
@@ -35,6 +35,15 @@ buildscript {
}
}
+//Remove doclint warnings that pollute javadoc logs when building with java8
+if(JavaVersion.current().isJava8()){
+ allprojects {
+ tasks.withType(Javadoc){
+ options.addStringOption('xdoclint:none','-quiet')
+ }
+ }
+}
+
allprojects {
apply plugin: 'java'
apply plugin: "eclipse"
@@ -48,7 +57,6 @@ allprojects {
apply plugin: "java-library"
apply plugin: 'signing'
apply plugin: 'checkstyle'
- apply plugin: 'com.github.jk1.dependency-license-report'
[compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
@@ -60,26 +68,10 @@ allprojects {
delete 'out'
}
- if ((project.findProperty("snapshot") instanceof String) && (Boolean.valueOf(project.property("snapshot")))) {
+ if ((project.findProperty("snapshot") instanceof String) && (Boolean.valueOf(project.property("snapshot") as boolean))) {
version = version + "-SNAPSHOT"
}
- licenseReport {
- allowedLicensesFile = new File("build/license/allowed-licenses.json")
- }
-
- checkLicense.doFirst {
- new File("build/license").mkdirs()
- new File("build/license/allowed-licenses.json").createNewFile()
-
- def writer = new File("build/license/allowed-licenses.json").newPrintWriter()
- new File("tool/license/allowed-licenses.txt").filterLine {
- String line -> line.trim().length() != 0 && !line.startsWith("#")
- }.writeTo(writer)
- writer.flush()
- writer.close()
- }
-
checkstyle {
toolVersion = '9.0'
ignoreFailures = false
@@ -153,6 +145,15 @@ task installPlugin() {
})
}
+task printProjects() {
+ getAllprojects().forEach(subProject -> {
+ if ("EventMesh".equals(subProject.getName())) {
+ return
+ }
+ println String.format("%s-%s.jar", subProject.getName(), subProject.getVersion())
+ })
+}
+
subprojects {
apply plugin: "io.spring.dependency-management"
@@ -247,6 +248,7 @@ subprojects {
new File("${projectDir}/dist/apps").mkdirs()
new File("${projectDir}/dist/conf").mkdirs()
new File("${projectDir}/dist/lib").mkdirs()
+ new File("${projectDir}/dist/licenses").mkdirs()
}
Set rootProject = ["eventmesh-admin",
"eventmesh-common",
@@ -298,6 +300,10 @@ subprojects {
from "${projectDir}/dist/conf"
}
}
+ copy {
+ into "${rootDir}/dist/licenses"
+ from "${rootDir}/tools/third-party-licenses/licenses"
+ }
}
}
@@ -402,17 +408,15 @@ subprojects {
dependencies {
dependency "org.apache.commons:commons-lang3:3.6"
dependency "org.apache.commons:commons-collections4:4.1"
- dependency "commons-io:commons-io:2.4"
dependency "org.apache.commons:commons-text:1.9"
- dependency "com.google.guava:guava:29.0-jre"
+ dependency "com.google.guava:guava:29.0-jre"
+
dependency "org.slf4j:slf4j-api:1.7.30"
- dependency "org.apache.logging.log4j:log4j-api:2.13.3"
- dependency "org.apache.logging.log4j:log4j-core:2.13.3"
- dependency "org.apache.logging.log4j:log4j-core:2.13.3"
- dependency "org.apache.logging.log4j:log4j-slf4j-impl:2.13.3"
- dependency "org.apache.logging.log4j:log4j-web:2.13.3"
+ dependency "org.apache.logging.log4j:log4j-api:2.16.0"
+ dependency "org.apache.logging.log4j:log4j-core:2.16.0"
+ dependency "org.apache.logging.log4j:log4j-slf4j-impl:2.16.0"
dependency "com.lmax:disruptor:3.4.2"
@@ -435,6 +439,8 @@ subprojects {
dependency 'io.opentelemetry:opentelemetry-exporter-prometheus:1.3.0-alpha'
dependency 'io.prometheus:simpleclient:0.8.1'
dependency 'io.prometheus:simpleclient_httpserver:0.8.1'
+ dependency 'io.opentelemetry:opentelemetry-exporter-zipkin:1.3.0'
+ dependency 'io.opentelemetry:opentelemetry-semconv:1.3.0-alpha'
dependency "io.openmessaging:openmessaging-api:2.2.1-pubsub"
@@ -442,6 +448,7 @@ subprojects {
dependency "com.mebigfatguy.fb-contrib:fb-contrib:7.4.7"
dependency "org.springframework.boot:spring-boot-starter-web:2.1.6.RELEASE"
+ dependency "io.openmessaging:registry-server:0.0.1"
dependency "junit:junit:4.12"
dependency "com.github.stefanbirkner:system-rules:1.16.1"
@@ -452,6 +459,12 @@ subprojects {
dependency "org.powermock:powermock-api-mockito2:2.0.2"
dependency "io.cloudevents:cloudevents-core:2.2.0"
+ dependency "io.cloudevents:cloudevents-json-jackson:2.2.0"
+
+ dependency "io.grpc:grpc-protobuf:1.15.0"
+ dependency "io.grpc:grpc-stub:1.15.0"
+ dependency "io.grpc:grpc-netty:1.15.0"
+ dependency "io.grpc:grpc-netty-shaded:1.15.0"
}
}
}
\ No newline at end of file
diff --git a/docker/eventmesh-rocketmq/Dockerfile b/docker/eventmesh-rocketmq/Dockerfile
index 5b61cc4f5d..fe9fe514ed 100644
--- a/docker/eventmesh-rocketmq/Dockerfile
+++ b/docker/eventmesh-rocketmq/Dockerfile
@@ -23,7 +23,7 @@ MAINTAINER mikexue mike_xwm@126.com
WORKDIR /data
RUN mkdir /data/app
-ADD EventMesh_1.2.0-SNAPSHOT.tar.gz /data/app/eventmesh
+ADD EventMesh_1.3.0-SNAPSHOT.tar.gz /data/app/eventmesh
WORKDIR /data/app/eventmesh/bin
EXPOSE 10000
diff --git a/docs/cn/features/https.md b/docs/cn/features/https.md
index 4c30527469..a100ba3977 100644
--- a/docs/cn/features/https.md
+++ b/docs/cn/features/https.md
@@ -17,12 +17,12 @@ config env varible
```
//创建producer
-LiteClientConfig liteClientConfig = new liteClientConfig();
+LiteClientConfig eventMeshHttpClientConfig = new eventMeshHttpClientConfig();
...
//设置开启TLS
-liteClientConfig.setUseTls(true);
-LiteProducer producer = new LiteProducer(liteClientConfig);
+eventMeshHttpClientConfig.setUseTls(true);
+LiteProducer producer = new LiteProducer(eventMeshHttpClientConfig);
//配置环境变量
diff --git a/docs/cn/features/spi.md b/docs/cn/features/spi.md
index b990d5956e..7499e655b1 100644
--- a/docs/cn/features/spi.md
+++ b/docs/cn/features/spi.md
@@ -101,7 +101,7 @@ public class RocketMQProducerImpl implements MeshMQProducer {
```
同时,还需要在eventmesh-connector-rocketmq模块中resource/META-INF/eventmesh目录下创建文件名为SPI接口全限定名的文件
-org.apache.eventmesh.api.producer.MeshMQProducer
+org.apache.eventmesh.api.producer.Producer
文件内容为扩展实例名和对应的实例全类名
diff --git a/docs/cn/instructions/eventmesh-runtime-quickstart.md b/docs/cn/instructions/eventmesh-runtime-quickstart.md
index d0982a7c47..990334d7cc 100644
--- a/docs/cn/instructions/eventmesh-runtime-quickstart.md
+++ b/docs/cn/instructions/eventmesh-runtime-quickstart.md
@@ -79,8 +79,7 @@ sh start.sh
```
- 文件加载:通过将插件安装到插件目录,EventMesh在运行时会根据条件自动加载插件目录下的插件,可以通过执行以下命令安装插件
```shell
-./gradlew clean jar dist
-./gradlew installPlugin
+./gradlew clean jar dist && ./gradlew installPlugin
```
***2.3.2.2 使用插件***
diff --git a/docs/en/features/eventmesh-trace-design.md b/docs/en/features/eventmesh-trace-design.md
new file mode 100644
index 0000000000..81e6c23b8a
--- /dev/null
+++ b/docs/en/features/eventmesh-trace-design.md
@@ -0,0 +1,89 @@
+# eventmesh-HTTP-trace-design
+
+## Introduction
+
+[EventMesh(incubating)](https://github.com/apache/incubator-eventmesh) is a dynamic cloud-native eventing infrastructure.
+
+## An overview of OpenTelemetry
+
+OpenTelemetry is a collection of tools, APIs, and SDKs. You can use it to instrument, generate, collect, and export telemetry data (metrics, logs, and traces) for analysis in order to understand your software's performance and behavior.
+
+## Requirements
+
+- set tracer
+- different exporter
+- start and end span in server
+
+## Design Details
+
+* SpanProcessor: BatchSpanProcessor
+
+* Exporter: log(default), would be changed from properties
+
+```java
+// Configure the batch spans processor. This span processor exports span in batches.
+BatchSpanProcessor batchSpansProcessor =
+ BatchSpanProcessor.builder(exporter)
+ .setMaxExportBatchSize(512) // set the maximum batch size to use
+ .setMaxQueueSize(2048) // set the queue size. This must be >= the export batch size
+ .setExporterTimeout(
+ 30, TimeUnit.SECONDS) // set the max amount of time an export can run before getting
+ // interrupted
+ .setScheduleDelay(5, TimeUnit.SECONDS) // set time between two different exports
+ .build();
+OpenTelemetrySdk.builder()
+ .setTracerProvider(
+ SdkTracerProvider.builder().addSpanProcessor(batchSpansProcessor).build())
+ .build();
+```
+
+1. When using the method 'init()' of the class "EventMeshHTTPServer", the class "AbstractHTTPServer” will get the tracer
+
+```java
+super.openTelemetryTraceFactory = new OpenTelemetryTraceFactory(eventMeshHttpConfiguration);
+super.tracer = openTelemetryTraceFactory.getTracer(this.getClass().toString());
+super.textMapPropagator = openTelemetryTraceFactory.getTextMapPropagator();
+```
+
+2. then the trace in class "AbstractHTTPServer” will work.
+
+## Problems
+
+#### How to set different exporter in class 'OpenTelemetryTraceFactory'?(Solved)
+
+After I get the exporter type from properties, how to deal with it.
+
+The 'logExporter' only needs to new it.
+
+But the 'zipkinExporter' needs to new and use the "getZipkinExporter()" method.
+
+## Solutions
+#### Solution of different exporter
+Use reflection to get an exporter.
+
+First of all, different exporter must implement the interface 'EventMeshExporter'.
+
+Then we get the exporter name from the configuration and reflect to the class.
+```java
+//different spanExporter
+String exporterName = configuration.eventMeshTraceExporterType;
+//use reflection to get spanExporter
+String className = String.format("org.apache.eventmesh.runtime.exporter.%sExporter",exporterName);
+EventMeshExporter eventMeshExporter = (EventMeshExporter) Class.forName(className).newInstance();
+spanExporter = eventMeshExporter.getSpanExporter(configuration);
+```
+
+Additional, this will surround with try catch.If the specified exporter cannot be obtained successfully, the default exporter log will be used instead
+
+#### Improvement of different exporter
+
+SPI(To be completed)
+
+
+## Appendix
+
+#### References
+
+https://github.com/open-telemetry/docs-cn/blob/main/QUICKSTART.md
+
+https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/netty
diff --git a/docs/en/features/https.md b/docs/en/features/https.md
index 8f928c135c..0ef6b5aa97 100644
--- a/docs/en/features/https.md
+++ b/docs/en/features/https.md
@@ -18,11 +18,11 @@ config env varible
```
// create producer
-LiteClientConfig liteClientConfig = new liteClientConfig();
+LiteClientConfig eventMeshHttpClientConfig = new eventMeshHttpClientConfig();
...
// enable TLS
-liteClientConfig.setUseTls(true);
-LiteProducer producer = new LiteProducer(liteClientConfig);
+eventMeshHttpClientConfig.setUseTls(true);
+LiteProducer producer = new LiteProducer(eventMeshHttpClientConfig);
config env varible
diff --git a/docs/en/features/spi.md b/docs/en/features/spi.md
index 1c26d17ed5..af1d62725e 100644
--- a/docs/en/features/spi.md
+++ b/docs/en/features/spi.md
@@ -105,7 +105,7 @@ public class RocketMQProducerImpl implements MeshMQProducer {
At the same time, we need to create a file with the full qualified name of the SPI interface under the resource/META-INF/eventmesh directory
in the eventmesh-connector-rocketmq module.
-org.apache.eventmesh.api.producer.MeshMQProducer
+org.apache.eventmesh.api.producer.Producer
The content of the file is the extension instance name and the corresponding instance full class name
diff --git a/docs/en/instructions/eventmesh-runtime-quickstart.md b/docs/en/instructions/eventmesh-runtime-quickstart.md
index a35ebbd3b1..2684c150c0 100644
--- a/docs/en/instructions/eventmesh-runtime-quickstart.md
+++ b/docs/en/instructions/eventmesh-runtime-quickstart.md
@@ -69,8 +69,7 @@ There are two ways to install the plugin:
- Install from files: By installing the plugin into the plugin directory, EventMesh will automatically load the plugins in the plugin directory
according to the conditions when EventMesh running, you can install the plugins by executing the following command.
```shell
-./gradlew clean jar dist
-./gradlew installPlugin
+./gradlew clean jar dist && ./gradlew installPlugin
```
***2.3.1.2 Use Plugin***
diff --git a/docs/en/instructions/eventmesh-store-quickstart.md b/docs/en/instructions/eventmesh-store-quickstart.md
index 74158e85fc..2c0df05600 100644
--- a/docs/en/instructions/eventmesh-store-quickstart.md
+++ b/docs/en/instructions/eventmesh-store-quickstart.md
@@ -8,49 +8,19 @@
Gradle at least 5.6, eg 5.6.*
4g+ free disk for eventmesh-store server
```
+### Standalone-connector
+No need a third-party store.
-### download sources
+### RocketMQ-connector
+you can reference https://rocketmq.apache.org/docs/quick-start/
-download source code from [https://github.com/WeBankFinTech/DeFiBus](https://github.com/WeBankFinTech/DeFiBus)
-You will get **DefiBus-master.zip**
+and "One-click" build script is on going.
-### build sources
+### Kafka-connector
+WIP
-The eventmesh-store takes DeFiBus for example at the following parts, because eventmesh depends on defibus as store layer
-by default, other implements such as Rocketmq etc. is coming soon.
-
-```
-unzip DefiBus-master.zip
-cd /*YOUR DEPLOY PATH*/DefiBus-master
-gradle clean dist tar -x test
-```
-
-You will get **DeFiBus_1.0.0.tar.gz** in directory /* YOUR DEPLOY PATH */DefiBus-master/build
-
-### Deployment
-
-- deploy DeFiBusNamesrv
-
-```
-upload DeFiBus_1.0.0.tar.gz
-tar -zxvf DeFiBus_1.0.0.tar.gz
-cd bin
-sh runnamesrv.sh
-```
-
-If you see "Thre Name Server boot success" in ../logs/namesrv.log, you setup DeFiBus Namesrv successfully.
-
-- deploy DeFiBusBroker
-
-```
-upload DeFiBus_1.0.0.tar.gz
-tar -zxvf DeFiBus_1.0.0.tar.gz
-cd conf
-config your broker.properties
-cd ../bin
-sh runbroker.sh
-```
-
-If you see "The broker \[YOUR-BROKER-NAME, IP:PORT\] boot success." in ../logs/broker.log, you setup eventmesh-store
-successfully.
+### Redis-connector
+WIP
+### DeFiBus-connector
+WIP
diff --git a/eventmesh-admin/README.md b/eventmesh-admin/README.md
index 84f80470d8..f97d2a937d 100644
--- a/eventmesh-admin/README.md
+++ b/eventmesh-admin/README.md
@@ -4,10 +4,10 @@ EventMesh Administration Module for EventMesh. It manages Admin Service, Configu
## Administration Client Manager APIs
-### POST /clientmanage/topics/
+### POST /topicmanage
- Create a new topic if does not exist
- Exposed POST endpoint to create a new topic if it does not exist.
- * Url - http://localhost:8081/clientmanage/topics/
+ * Url - http://localhost:8081/topicmanage
* sample request payload
```json
{
@@ -23,12 +23,12 @@ EventMesh Administration Module for EventMesh. It manages Admin Service, Configu
"created_time": "2021-09-03",
}
```
-### DELETE /clientmanage/topics/(string: topic)/
+### DELETE /topicmanage/(string: topic)
- Delete a specific topic.
- Exposed DELETE endpoint to remove a specific topic
* URL -
```url
- http://localhost:8081/clientmanage/topics/mytopic1
+ http://localhost:8081/topicmanage/mytopic1
```
* Response -
@@ -39,12 +39,12 @@ EventMesh Administration Module for EventMesh. It manages Admin Service, Configu
}
```
-### GET /clientmanage/topics
+### GET /topicmanage
- Retrieve a list of topics
- Exposed GET endpoint to retrieve all topics
* URL -
```url
- http://localhost:8081/clientmanage/topics
+ http://localhost:8081/topicmanage
```
* Response
diff --git a/eventmesh-admin/build.gradle b/eventmesh-admin/build.gradle
index 2bbbee28ff..0741bc6d52 100644
--- a/eventmesh-admin/build.gradle
+++ b/eventmesh-admin/build.gradle
@@ -15,5 +15,22 @@
* limitations under the License.
*/
-dependencies {
+task copyEventMeshAdmin(dependsOn: ['jar']) {
+ doFirst {
+ new File(projectDir, '../eventmesh-admin/dist/apps').mkdir()
+ new File(projectDir, '../dist/admin/').mkdirs()
+ }
+ doLast {
+ copy {
+ into('../eventmesh-admin/dist/apps/')
+ from project.jar.getArchivePath()
+ exclude {
+ "eventmesh-admin-${version}.jar"
+ }
+ }
+ copy {
+ into '../dist/admin'
+ from "../eventmesh-admin/dist/apps/eventmesh-admin-rocketmq-${version}.jar"
+ }
+ }
}
\ No newline at end of file
diff --git a/eventmesh-admin/eventmesh-admin-rocketmq/build.gradle b/eventmesh-admin/eventmesh-admin-rocketmq/build.gradle
new file mode 100644
index 0000000000..1217b33818
--- /dev/null
+++ b/eventmesh-admin/eventmesh-admin-rocketmq/build.gradle
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+dependencies {
+ compileOnly project(":eventmesh-common")
+
+ implementation "org.apache.httpcomponents:httpclient"
+ implementation "com.fasterxml.jackson.core:jackson-databind"
+ implementation "com.fasterxml.jackson.core:jackson-core"
+ implementation "com.fasterxml.jackson.core:jackson-annotations"
+
+ implementation project(":eventmesh-connector-plugin:eventmesh-connector-api")
+
+ testImplementation project(":eventmesh-connector-plugin:eventmesh-connector-api")
+}
diff --git a/eventmesh-registry-plugin/eventmesh-registry-namesrv/gradle.properties b/eventmesh-admin/eventmesh-admin-rocketmq/gradle.properties
similarity index 95%
rename from eventmesh-registry-plugin/eventmesh-registry-namesrv/gradle.properties
rename to eventmesh-admin/eventmesh-admin-rocketmq/gradle.properties
index ace94b43e0..3d49f4c756 100644
--- a/eventmesh-registry-plugin/eventmesh-registry-namesrv/gradle.properties
+++ b/eventmesh-admin/eventmesh-admin-rocketmq/gradle.properties
@@ -14,5 +14,4 @@
# limitations under the License.
#
-pluginType=registry
-pluginName=namesrv
\ No newline at end of file
+rocketmq_version=4.7.1
\ No newline at end of file
diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/exception/OpenSchemaExceptionHandler.java b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/controller/AdminController.java
similarity index 55%
rename from eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/exception/OpenSchemaExceptionHandler.java
rename to eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/controller/AdminController.java
index eebc97964b..8932afd5cb 100644
--- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/exception/OpenSchemaExceptionHandler.java
+++ b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/controller/AdminController.java
@@ -14,17 +14,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.eventmesh.schema.registry.server.exception;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.ControllerAdvice;
-import org.springframework.web.bind.annotation.ExceptionHandler;
+package org.apache.eventmesh.admin.rocketmq.controller;
-@ControllerAdvice
-public class OpenSchemaExceptionHandler {
+import org.apache.eventmesh.admin.rocketmq.handler.TopicsHandler;
- @ExceptionHandler(value = OpenSchemaException.class)
- public ResponseEntity exceptionHandler(OpenSchemaException e){
- return ResponseEntity.status(e.getErr_status().value()).body(new ErrorResponse(e.getErr_code(), e.getErr_message()));
+import java.io.IOException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.sun.net.httpserver.HttpServer;
+
+public class AdminController {
+
+ private static final Logger logger = LoggerFactory.getLogger(AdminController.class);
+
+ public AdminController() {
+ }
+
+ public void run(HttpServer server) throws IOException {
+
+ server.createContext("/topicmanage", new TopicsHandler());
+
+ logger.info("EventMesh-Admin Controller server context created successfully");
}
}
diff --git a/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/handler/TopicsHandler.java b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/handler/TopicsHandler.java
new file mode 100644
index 0000000000..345f4bca30
--- /dev/null
+++ b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/handler/TopicsHandler.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.admin.rocketmq.handler;
+
+import org.apache.eventmesh.admin.rocketmq.request.TopicCreateRequest;
+import org.apache.eventmesh.admin.rocketmq.response.TopicResponse;
+import org.apache.eventmesh.admin.rocketmq.util.JsonUtils;
+import org.apache.eventmesh.admin.rocketmq.util.NetUtils;
+import org.apache.eventmesh.admin.rocketmq.util.RequestMapping;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+
+public class TopicsHandler implements HttpHandler {
+ private static final Logger logger = LoggerFactory.getLogger(TopicsHandler.class);
+
+ @Override
+ public void handle(HttpExchange httpExchange) throws IOException {
+
+ // create a new topic
+ if (RequestMapping.postMapping("/topicmanage", httpExchange)) {
+ createTopicHandler(httpExchange);
+ return;
+ }
+
+ OutputStream out = httpExchange.getResponseBody();
+ httpExchange.sendResponseHeaders(500, 0);
+ String result = String.format("Please check your request url");
+ logger.error(result);
+ out.write(result.getBytes());
+ return;
+ }
+
+ public void createTopicHandler(HttpExchange httpExchange) throws IOException {
+ String result = "";
+ OutputStream out = httpExchange.getResponseBody();
+ try {
+ String params = NetUtils.parsePostBody(httpExchange);
+ TopicCreateRequest topicCreateRequest =
+ JsonUtils.toObject(params, TopicCreateRequest.class);
+ String topic = topicCreateRequest.getName();
+
+ if (StringUtils.isBlank(topic)) {
+ result = "Create topic failed. Parameter topic not found.";
+ logger.error(result);
+ out.write(result.getBytes());
+ return;
+ }
+
+ //TBD: A new rocketmq service will be implemented for creating topics
+ TopicResponse topicResponse = null;
+ if (topicResponse != null) {
+ logger.info("create a new topic: {}", topic);
+ httpExchange.getResponseHeaders().add("Content-Type", "appication/json");
+ httpExchange.sendResponseHeaders(200, 0);
+ result = JsonUtils.toJson(topicResponse);
+ logger.info(result);
+ out.write(result.getBytes());
+ return;
+ } else {
+ httpExchange.sendResponseHeaders(500, 0);
+ result = String.format("create topic failed! Server side error");
+ logger.error(result);
+ out.write(result.getBytes());
+ return;
+ }
+ } catch (Exception e) {
+ httpExchange.getResponseHeaders().add("Content-Type", "appication/json");
+ httpExchange.sendResponseHeaders(500, 0);
+ result = String.format("create topic failed! Server side error");
+ logger.error(result);
+ out.write(result.getBytes());
+ return;
+ } finally {
+ if (out != null) {
+ try {
+ out.close();
+ } catch (IOException e) {
+ logger.warn("out close failed...", e);
+ }
+ }
+ }
+ }
+
+}
diff --git a/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/request/TopicCreateRequest.java b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/request/TopicCreateRequest.java
new file mode 100644
index 0000000000..7adaa77cd2
--- /dev/null
+++ b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/request/TopicCreateRequest.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.admin.rocketmq.request;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonInclude(JsonInclude.Include.NON_EMPTY)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class TopicCreateRequest {
+
+ private String name;
+
+ @JsonCreator
+ public TopicCreateRequest(@JsonProperty("name") String topic) {
+ super();
+ this.name = topic;
+ }
+
+ @JsonProperty("name")
+ public String getName() {
+ return this.name;
+ }
+
+ @JsonProperty("name")
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
diff --git a/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/response/TopicResponse.java b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/response/TopicResponse.java
new file mode 100644
index 0000000000..1dde496bcb
--- /dev/null
+++ b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/response/TopicResponse.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.admin.rocketmq.response;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class TopicResponse {
+
+ private String topic;
+ private String createdTime;
+
+ @JsonCreator
+ public TopicResponse(@JsonProperty("topic") String topic,
+ @JsonProperty("created_time") String createdTime) {
+ super();
+ this.topic = topic;
+ this.createdTime = createdTime;
+ }
+
+ @JsonProperty("topic")
+ public String getTopic() {
+ return this.topic;
+ }
+
+ @JsonProperty("topic")
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+ @JsonProperty("created_time")
+ public String getCreatedTime() {
+ return createdTime;
+ }
+
+ @JsonProperty("created_time")
+ public void setCreatedTime(String createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("TopicResponse {topic=" + this.topic + ",");
+ sb.append("created_time=" + this.createdTime + "}");
+ return sb.toString();
+ }
+
+}
diff --git a/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/JsonUtils.java b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/JsonUtils.java
new file mode 100644
index 0000000000..69455c5db5
--- /dev/null
+++ b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/JsonUtils.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.admin.rocketmq.util;
+
+import java.io.IOException;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+
+public class JsonUtils {
+
+ private static ObjectMapper objectMapper;
+
+ static {
+ objectMapper = new ObjectMapper();
+ objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
+ objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
+ }
+
+ public static byte[] serialize(String topic, Class data) throws JsonProcessingException {
+ if (data == null) {
+ return null;
+ }
+ return objectMapper.writeValueAsBytes(data);
+ }
+
+ public static String toJson(Object obj) throws JsonProcessingException {
+ if (obj == null) {
+ return null;
+ }
+ return objectMapper.writeValueAsString(obj);
+ }
+
+ public static T toObject(String json, Class clazz) throws JsonProcessingException {
+ return objectMapper.readValue(json, clazz);
+ }
+
+ public static T deserialize(Class clazz, byte[] bytes) throws IOException {
+ if (bytes == null || bytes.length == 0) {
+ return null;
+ }
+
+ return objectMapper.readValue(bytes, clazz);
+ }
+
+ public static T deserialize(Class clazz, String json) throws IOException {
+ if (json == null || json.length() == 0) {
+ return null;
+ }
+
+ return objectMapper.readValue(json, clazz);
+ }
+}
diff --git a/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/NetUtils.java b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/NetUtils.java
new file mode 100644
index 0000000000..c6c7992d2e
--- /dev/null
+++ b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/NetUtils.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.admin.rocketmq.util;
+
+import org.apache.http.Consts;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.sun.net.httpserver.HttpExchange;
+
+public class NetUtils {
+
+ private static final Logger logger = LoggerFactory.getLogger(NetUtils.class);
+
+ public static String parsePostBody(HttpExchange exchange)
+ throws IOException {
+ StringBuilder body = new StringBuilder();
+ if ("post".equalsIgnoreCase(exchange.getRequestMethod())
+ || "put".equalsIgnoreCase(exchange.getRequestMethod())) {
+ try (InputStreamReader reader =
+ new InputStreamReader(exchange.getRequestBody(), Consts.UTF_8)) {
+ char[] buffer = new char[256];
+ int read;
+ while ((read = reader.read(buffer)) != -1) {
+ body.append(buffer, 0, read);
+ }
+ }
+ }
+ return body.toString();
+ }
+}
+
diff --git a/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/RequestMapping.java b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/RequestMapping.java
new file mode 100644
index 0000000000..b093d3e9f3
--- /dev/null
+++ b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/RequestMapping.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.admin.rocketmq.util;
+
+import com.sun.net.httpserver.HttpExchange;
+
+public class RequestMapping {
+
+ public static boolean postMapping(String value, HttpExchange httpExchange) {
+ if ("post".equalsIgnoreCase(httpExchange.getRequestMethod())) {
+ String requestUri = httpExchange.getRequestURI().getPath();
+ UrlMappingPattern matcher = new UrlMappingPattern(value);
+ return matcher.matches(requestUri);
+ }
+ return false;
+ }
+
+ public static boolean getMapping(String value, HttpExchange httpExchange) {
+ if ("get".equalsIgnoreCase(httpExchange.getRequestMethod())) {
+ String requestUri = httpExchange.getRequestURI().getPath();
+ UrlMappingPattern matcher = new UrlMappingPattern(value);
+ return matcher.matches(requestUri);
+ }
+ return false;
+ }
+
+ public static boolean putMapping(String value, HttpExchange httpExchange) {
+ if ("put".equalsIgnoreCase(httpExchange.getRequestMethod())) {
+ String requestUri = httpExchange.getRequestURI().getPath();
+ UrlMappingPattern matcher = new UrlMappingPattern(value);
+ return matcher.matches(requestUri);
+ }
+ return false;
+ }
+
+ public static boolean deleteMapping(String value, HttpExchange httpExchange) {
+ if ("delete".equalsIgnoreCase(httpExchange.getRequestMethod())) {
+ String requestUri = httpExchange.getRequestURI().getPath();
+ UrlMappingPattern matcher = new UrlMappingPattern(value);
+ return matcher.matches(requestUri);
+ }
+ return false;
+ }
+
+}
diff --git a/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/UrlMappingPattern.java b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/UrlMappingPattern.java
new file mode 100644
index 0000000000..0e31b13ca1
--- /dev/null
+++ b/eventmesh-admin/eventmesh-admin-rocketmq/src/main/java/org/apache/eventmesh/admin/rocketmq/util/UrlMappingPattern.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.admin.rocketmq.util;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class UrlMappingPattern {
+
+ private static final String URL_PARAMETER_REGEX = "\\{(\\w*?)\\}";
+
+ private static final String URL_PARAMETER_MATCH_REGEX =
+ "\\([%\\\\w-.\\\\~!\\$&'\\\\(\\\\)\\\\*\\\\+,;=:\\\\[\\\\]@]+?\\)";
+
+ private static final Pattern URL_PARAMETER_PATTERN = Pattern.compile(URL_PARAMETER_REGEX);
+
+ private static final String URL_FORMAT_REGEX = "(?:\\.\\{format\\})$";
+
+ private static final String URL_FORMAT_MATCH_REGEX = "(?:\\\\.\\([\\\\w%]+?\\))?";
+
+ private static final String URL_QUERY_STRING_REGEX = "(?:\\?.*?)?$";
+
+ private String urlMappingPattern;
+
+ private Pattern compiledUrlMappingPattern;
+
+ private List paramNames = new ArrayList();
+
+ public UrlMappingPattern(String pattern) {
+ super();
+ setUrlMappingPattern(pattern);
+ compile();
+ }
+
+ public String getMappingPattern() {
+ return getUrlMappingPattern().replaceFirst(URL_FORMAT_REGEX, "");
+ }
+
+ private String getUrlMappingPattern() {
+ return urlMappingPattern;
+ }
+
+ public Map extractPathParameterValues(String url) {
+ Matcher matcher = compiledUrlMappingPattern.matcher(url);
+ if (matcher.matches()) {
+ return extractParameters(matcher);
+ }
+ return null;
+ }
+
+ public boolean matches(String url) {
+ return (extractPathParameterValues(url) != null);
+ }
+
+ public void compile() {
+ acquireParamNames();
+ String parsedPattern =
+ getUrlMappingPattern().replaceFirst(URL_FORMAT_REGEX, URL_FORMAT_MATCH_REGEX);
+ parsedPattern = parsedPattern.replaceAll(URL_PARAMETER_REGEX, URL_PARAMETER_MATCH_REGEX);
+ this.compiledUrlMappingPattern = Pattern.compile(parsedPattern + URL_QUERY_STRING_REGEX);
+ }
+
+ private void acquireParamNames() {
+ Matcher m = URL_PARAMETER_PATTERN.matcher(getUrlMappingPattern());
+ while (m.find()) {
+ paramNames.add(m.group(1));
+ }
+ }
+
+ private Map extractParameters(Matcher matcher) {
+ Map values = new HashMap();
+ for (int i = 0; i < matcher.groupCount(); i++) {
+ String value = matcher.group(i + 1);
+
+ if (value != null) {
+ values.put(paramNames.get(i), value);
+ }
+ }
+ return values;
+ }
+
+ private void setUrlMappingPattern(String pattern) {
+ this.urlMappingPattern = pattern;
+ }
+
+ public List getParamNames() {
+ return Collections.unmodifiableList(paramNames);
+ }
+}
diff --git a/eventmesh-common/build.gradle b/eventmesh-common/build.gradle
index b552781545..d373fe1e71 100644
--- a/eventmesh-common/build.gradle
+++ b/eventmesh-common/build.gradle
@@ -16,47 +16,47 @@
*/
dependencies {
- api "org.apache.commons:commons-lang3"
- api "org.apache.commons:commons-collections4"
api "com.google.guava:guava"
api "org.slf4j:slf4j-api"
api "junit:junit"
api "org.assertj:assertj-core"
-
- implementation "commons-io:commons-io"
- implementation "org.apache.commons:commons-text"
+ api "org.apache.commons:commons-collections4"
+ api "org.apache.commons:commons-text"
+ api "org.apache.commons:commons-lang3"
implementation "org.apache.logging.log4j:log4j-api"
implementation "org.apache.logging.log4j:log4j-core"
- implementation "org.apache.logging.log4j:log4j-core"
implementation "org.apache.logging.log4j:log4j-slf4j-impl"
- implementation "org.apache.logging.log4j:log4j-web"
implementation "com.lmax:disruptor"
- implementation "com.fasterxml.jackson.core:jackson-databind"
- implementation "com.fasterxml.jackson.core:jackson-core"
- implementation "com.fasterxml.jackson.core:jackson-annotations"
+ api "com.fasterxml.jackson.core:jackson-databind"
+ api "com.fasterxml.jackson.core:jackson-core"
+ api "com.fasterxml.jackson.core:jackson-annotations"
implementation "org.apache.httpcomponents:httpclient"
implementation "io.netty:netty-all"
+ implementation "io.grpc:grpc-protobuf:1.15.0"
+ implementation "io.grpc:grpc-stub:1.15.0"
+
implementation "com.github.stefanbirkner:system-rules"
+ compileOnly 'org.projectlombok:lombok:1.18.22'
+ annotationProcessor 'org.projectlombok:lombok:1.18.22'
+
+ testCompileOnly 'org.projectlombok:lombok:1.18.22'
+ testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
+
testImplementation "org.apache.commons:commons-lang3"
- testImplementation "org.apache.commons:commons-collections4"
- testImplementation "commons-io:commons-io"
- testImplementation "org.apache.commons:commons-text"
testImplementation "com.google.guava:guava"
testImplementation "org.slf4j:slf4j-api"
testImplementation "org.apache.logging.log4j:log4j-api"
testImplementation "org.apache.logging.log4j:log4j-core"
- testImplementation "org.apache.logging.log4j:log4j-core"
testImplementation "org.apache.logging.log4j:log4j-slf4j-impl"
- testImplementation "org.apache.logging.log4j:log4j-web"
testImplementation "com.lmax:disruptor"
@@ -69,7 +69,6 @@ dependencies {
testImplementation "io.netty:netty-all"
testImplementation "junit:junit"
- testImplementation "com.github.stefanbirkner:system-rules"
testImplementation "org.assertj:assertj-core"
testImplementation "org.mockito:mockito-core"
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/Constants.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/Constants.java
index c2457addc6..af222fd8c6 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/Constants.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/Constants.java
@@ -29,6 +29,12 @@ public class Constants {
public static final String HTTPS_PROTOCOL_PREFIX = "https://";
+ public static final String PROTOCOL_TYPE = "protocoltype";
+
+ public static final String PROTOCOL_VERSION = "protocolversion";
+
+ public static final String PROTOCOL_DESC = "protocoldesc";
+
public static final int DEFAULT_HTTP_TIME_OUT = 3000;
public static final String EVENTMESH_MESSAGE_CONST_TTL = "ttl";
@@ -51,28 +57,30 @@ public class Constants {
public static final String KEY_CONSTANTS_INSTANCE_DESC_PID = "pid";
- public static final String RMB_UNIQ_ID = "RMB_UNIQ_ID";
+ public static final String RMB_UNIQ_ID = "rmbuniqid";
public static final String IDC_SEPERATER = "-";
- public static final String PROPERTY_MESSAGE_TIMEOUT = "TIMEOUT";
+ public static final String PROPERTY_MESSAGE_TIMEOUT = "timeout";
+
+ public static final String PROPERTY_MESSAGE_SEARCH_KEYS = "searchkeys";
- public static final String PROPERTY_MESSAGE_SEARCH_KEYS = "SEARCH_KEYS";
+ public static final String PROPERTY_MESSAGE_QUEUE_ID = "queueid";
- public static final String PROPERTY_MESSAGE_QUEUE_ID = "QUEUE_ID";
+ public static final String PROPERTY_MESSAGE_QUEUE_OFFSET = "queueoffset";
- public static final String PROPERTY_MESSAGE_QUEUE_OFFSET = "QUEUE_OFFSET";
+ public static final String PROPERTY_MESSAGE_DESTINATION = "destination";
- public static final String PROPERTY_MESSAGE_DESTINATION = "DESTINATION";
+ public static final String PROPERTY_MESSAGE_MESSAGE_ID = "messageid";
- public static final String PROPERTY_MESSAGE_MESSAGE_ID = "MESSAGE_ID";
+ public static final String PROPERTY_MESSAGE_BORN_HOST = "bornhost";
- public static final String PROPERTY_MESSAGE_BORN_HOST = "BORN_HOST";
+ public static final String PROPERTY_MESSAGE_BORN_TIMESTAMP = "borntimestamp";
- public static final String PROPERTY_MESSAGE_BORN_TIMESTAMP = "BORN_TIMESTAMP";
+ public static final String PROPERTY_MESSAGE_STORE_HOST = "storehost";
- public static final String PROPERTY_MESSAGE_STORE_HOST = "STORE_HOST";
+ public static final String PROPERTY_MESSAGE_STORE_TIMESTAMP = "storetimestamp";
- public static final String PROPERTY_MESSAGE_STORE_TIMESTAMP = "STORE_TIMESTAMP";
+ public static final String MESSAGE_PROP_SEPARATOR = "99";
}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshMessage.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshMessage.java
new file mode 100644
index 0000000000..8fecc700fe
--- /dev/null
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshMessage.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.common;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import lombok.Builder;
+import lombok.Data;
+
+/**
+ * EventMesh message.
+ */
+@Builder
+@Data
+public class EventMeshMessage {
+
+ private String bizSeqNo;
+
+ private String uniqueId;
+
+ private String topic;
+
+ private String content;
+
+ private Map prop;
+
+ @Builder.Default
+ private final long createTime = System.currentTimeMillis();
+
+ public EventMeshMessage addProp(String key, String val) {
+ if (prop == null) {
+ prop = new HashMap<>();
+ }
+ prop.put(key, val);
+ return this;
+ }
+
+ public String getProp(String key) {
+ if (prop == null) {
+ return null;
+ }
+ return prop.get(key);
+ }
+
+ public EventMeshMessage removePropIfPresent(String key) {
+ if (prop == null) {
+
+ return this;
+ }
+ prop.remove(key);
+ return this;
+ }
+
+}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/LiteMessage.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/LiteMessage.java
deleted file mode 100644
index 455dfc65d0..0000000000
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/LiteMessage.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.eventmesh.common;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.lang3.time.DateFormatUtils;
-
-public class LiteMessage {
-
- private String bizSeqNo;
-
- private String uniqueId;
-
- private String topic;
-
- private String content;
-
- private Map prop;
-
- private long createTime = System.currentTimeMillis();
-
- public LiteMessage() {
- }
-
- public LiteMessage(String bizSeqno, String uniqueId, String topic,
- String content) {
- this.bizSeqNo = bizSeqno;
- this.uniqueId = uniqueId;
- this.topic = topic;
- this.content = content;
- }
-
- public Map getProp() {
- return prop;
- }
-
- public LiteMessage setProp(Map prop) {
- this.prop = prop;
- return this;
- }
-
- public LiteMessage addProp(String key, String val) {
- if (prop == null) {
- prop = new HashMap();
- }
- prop.put(key, val);
- return this;
- }
-
- public String getPropKey(String key) {
- if (prop == null) {
- return null;
- }
- return prop.get(key);
- }
-
- public LiteMessage removeProp(String key) {
- if (prop == null) {
- return this;
- }
- prop.remove(key);
- return this;
- }
-
- public String getBizSeqNo() {
- return bizSeqNo;
- }
-
- public LiteMessage setBizSeqNo(String bizSeqNo) {
- this.bizSeqNo = bizSeqNo;
- return this;
- }
-
- public String getUniqueId() {
- return uniqueId;
- }
-
- public LiteMessage setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- return this;
- }
-
- public String getTopic() {
- return topic;
- }
-
- public LiteMessage setTopic(String topic) {
- this.topic = topic;
- return this;
- }
-
- public String getContent() {
- return content;
- }
-
- public LiteMessage setContent(String content) {
- this.content = content;
- return this;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("liteMessage={")
- .append("bizSeqNo=").append(bizSeqNo).append(",")
- .append("uniqueId=").append(uniqueId).append(",")
- .append("topic=").append(topic).append(",")
- .append("content=").append(content).append(",")
- .append("prop=").append(prop).append(",")
- .append("createTime=").append(DateFormatUtils.format(createTime, Constants.DATE_FORMAT))
- .append("}");
- return sb.toString();
- }
-}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadPoolFactory.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadPoolFactory.java
index 5be65297b3..319673d247 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadPoolFactory.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadPoolFactory.java
@@ -26,37 +26,32 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+
public class ThreadPoolFactory {
public static ThreadPoolExecutor createThreadPoolExecutor(int core, int max, final String threadName) {
return createThreadPoolExecutor(core, max, threadName, true);
}
- public static ThreadPoolExecutor createThreadPoolExecutor(int core, int max, final String threadName, final boolean isDaemon) {
+ public static ThreadPoolExecutor createThreadPoolExecutor(int core, int max, final String threadName,
+ final boolean isDaemon) {
return createThreadPoolExecutor(core, max, new LinkedBlockingQueue(1000), threadName, isDaemon);
}
- public static ThreadPoolExecutor createThreadPoolExecutor(int core, int max, BlockingQueue blockingQueue, final String threadName, final boolean isDaemon) {
- return new ThreadPoolExecutor(core, max,
- 10 * 1000, TimeUnit.MILLISECONDS, blockingQueue, new ThreadFactory() {
-
- private AtomicInteger seq = new AtomicInteger(0);
-
- @Override
- public Thread newThread(Runnable r) {
- seq.incrementAndGet();
- Thread t = new Thread(r, threadName + seq.get());
- t.setDaemon(isDaemon);
- return t;
- }
- });
+ public static ThreadPoolExecutor createThreadPoolExecutor(int core, int max, BlockingQueue blockingQueue,
+ final String threadName, final boolean isDaemon) {
+ return new ThreadPoolExecutor(core, max, 10 * 1000, TimeUnit.MILLISECONDS, blockingQueue,
+ new ThreadFactoryBuilder().setNameFormat(threadName).setDaemon(isDaemon).build()
+ );
}
public static ThreadPoolExecutor createThreadPoolExecutor(int core, int max, ThreadFactory threadFactory) {
return createThreadPoolExecutor(core, max, new LinkedBlockingQueue(1000), threadFactory);
}
- public static ThreadPoolExecutor createThreadPoolExecutor(int core, int max, BlockingQueue blockingQueue, ThreadFactory threadFactory) {
+ public static ThreadPoolExecutor createThreadPoolExecutor(int core, int max, BlockingQueue blockingQueue,
+ ThreadFactory threadFactory) {
return new ThreadPoolExecutor(core, max, 10 * 1000, TimeUnit.MILLISECONDS, blockingQueue, threadFactory);
}
@@ -77,7 +72,8 @@ public static ScheduledExecutorService createScheduledExecutor(int core, final S
return createScheduledExecutor(core, threadName, true);
}
- public static ScheduledExecutorService createScheduledExecutor(int core, final String threadName, final boolean isDaemon) {
+ public static ScheduledExecutorService createScheduledExecutor(int core, final String threadName,
+ final boolean isDaemon) {
return Executors.newScheduledThreadPool(core, new ThreadFactory() {
private AtomicInteger ai = new AtomicInteger(0);
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java
index 2c6b37d63c..33e9ce950e 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java
@@ -20,7 +20,7 @@
import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
-import org.apache.eventmesh.common.IPUtil;
+import org.apache.eventmesh.common.utils.IPUtils;
public class CommonConfiguration {
public String eventMeshEnv = "P";
@@ -32,6 +32,13 @@ public class CommonConfiguration {
public String eventMeshSecurityPluginType = "security";
public int eventMeshPrometheusPort = 19090;
public String eventMeshRegistryPluginType = "namesrv";
+ public String eventMeshTraceExporterType = "Log";
+ public int eventMeshTraceExporterMaxExportSize = 512;
+ public int eventMeshTraceExporterMaxQueueSize = 2048;
+ public int eventMeshTraceExporterExportTimeout = 30;
+ public int eventMeshTraceExporterExportInterval = 5;
+ public String eventMeshTraceExportZipkinIp = "localhost";
+ public int eventMeshTraceExportZipkinPort = 9411;
public String namesrvAddr = "";
public Integer eventMeshRegisterIntervalInMills = 10 * 1000;
@@ -48,54 +55,125 @@ public CommonConfiguration(ConfigurationWrapper configurationWrapper) {
public void init() {
if (configurationWrapper != null) {
- String eventMeshEnvStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ENV);
- Preconditions.checkState(StringUtils.isNotEmpty(eventMeshEnvStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ENV));
+ String eventMeshEnvStr =
+ configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ENV);
+ Preconditions.checkState(StringUtils.isNotEmpty(eventMeshEnvStr),
+ String.format("%s error", ConfKeys.KEYS_EVENTMESH_ENV));
eventMeshEnv = StringUtils.deleteWhitespace(eventMeshEnvStr);
- String sysIdStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SYSID);
- Preconditions.checkState(StringUtils.isNotEmpty(sysIdStr) && StringUtils.isNumeric(sysIdStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SYSID));
+ String sysIdStr =
+ configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SYSID);
+ Preconditions.checkState(StringUtils.isNotEmpty(sysIdStr) && StringUtils.isNumeric(sysIdStr),
+ String.format("%s error", ConfKeys.KEYS_EVENTMESH_SYSID));
sysID = StringUtils.deleteWhitespace(sysIdStr);
- String eventMeshClusterStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_CLUSTER);
- Preconditions.checkState(StringUtils.isNotEmpty(eventMeshClusterStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_CLUSTER));
+ String eventMeshClusterStr =
+ configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_CLUSTER);
+ Preconditions.checkState(StringUtils.isNotEmpty(eventMeshClusterStr),
+ String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_CLUSTER));
eventMeshCluster = StringUtils.deleteWhitespace(eventMeshClusterStr);
- String eventMeshNameStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_NAME);
- Preconditions.checkState(StringUtils.isNotEmpty(eventMeshNameStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_NAME));
+ String eventMeshNameStr =
+ configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_NAME);
+ Preconditions.checkState(StringUtils.isNotEmpty(eventMeshNameStr),
+ String.format("%s error", ConfKeys.KEYS_EVENTMESH_SERVER_NAME));
eventMeshName = StringUtils.deleteWhitespace(eventMeshNameStr);
- String eventMeshIDCStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_IDC);
- Preconditions.checkState(StringUtils.isNotEmpty(eventMeshIDCStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_IDC));
- eventMeshIDC = StringUtils.deleteWhitespace(eventMeshIDCStr);
+ String eventMeshIdcStr =
+ configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_IDC);
+ Preconditions.checkState(StringUtils.isNotEmpty(eventMeshIdcStr),
+ String.format("%s error", ConfKeys.KEYS_EVENTMESH_IDC));
+ eventMeshIDC = StringUtils.deleteWhitespace(eventMeshIdcStr);
- String eventMeshPrometheusPortStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_METRICS_PROMETHEUS_PORT);
+ String eventMeshPrometheusPortStr =
+ configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_METRICS_PROMETHEUS_PORT);
if (StringUtils.isNotEmpty(eventMeshPrometheusPortStr)) {
- eventMeshPrometheusPort = Integer.valueOf(StringUtils.deleteWhitespace(eventMeshPrometheusPortStr));
+ eventMeshPrometheusPort =
+ Integer.valueOf(StringUtils.deleteWhitespace(eventMeshPrometheusPortStr));
}
- eventMeshServerIp = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_HOST_IP);
+ eventMeshServerIp =
+ configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SERVER_HOST_IP);
if (StringUtils.isBlank(eventMeshServerIp)) {
- eventMeshServerIp = IPUtil.getLocalAddress();
+ eventMeshServerIp = IPUtils.getLocalAddress();
}
- eventMeshConnectorPluginType = configurationWrapper.getProp(ConfKeys.KEYS_ENENTMESH_CONNECTOR_PLUGIN_TYPE);
- Preconditions.checkState(StringUtils.isNotEmpty(eventMeshConnectorPluginType), String.format("%s error", ConfKeys.KEYS_ENENTMESH_CONNECTOR_PLUGIN_TYPE));
+ eventMeshConnectorPluginType =
+ configurationWrapper.getProp(ConfKeys.KEYS_ENENTMESH_CONNECTOR_PLUGIN_TYPE);
+ Preconditions.checkState(StringUtils.isNotEmpty(eventMeshConnectorPluginType),
+ String.format("%s error", ConfKeys.KEYS_ENENTMESH_CONNECTOR_PLUGIN_TYPE));
- String eventMeshServerAclEnableStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SECURITY_ENABLED);
+ String eventMeshServerAclEnableStr =
+ configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_SECURITY_ENABLED);
if (StringUtils.isNotBlank(eventMeshServerAclEnableStr)) {
- eventMeshServerSecurityEnable = Boolean.valueOf(StringUtils.deleteWhitespace(eventMeshServerAclEnableStr));
+ eventMeshServerSecurityEnable =
+ Boolean.valueOf(StringUtils.deleteWhitespace(eventMeshServerAclEnableStr));
}
- eventMeshSecurityPluginType = configurationWrapper.getProp(ConfKeys.KEYS_ENENTMESH_SECURITY_PLUGIN_TYPE);
- Preconditions.checkState(StringUtils.isNotEmpty(eventMeshSecurityPluginType), String.format("%s error", ConfKeys.KEYS_ENENTMESH_SECURITY_PLUGIN_TYPE));
+ eventMeshSecurityPluginType =
+ configurationWrapper.getProp(ConfKeys.KEYS_ENENTMESH_SECURITY_PLUGIN_TYPE);
+ Preconditions.checkState(StringUtils.isNotEmpty(eventMeshSecurityPluginType),
+ String.format("%s error", ConfKeys.KEYS_ENENTMESH_SECURITY_PLUGIN_TYPE));
- String eventMeshServerRegistryEnableStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_REGISTRY_ENABLED);
+ String eventMeshServerRegistryEnableStr =
+ configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_REGISTRY_ENABLED);
if (StringUtils.isNotBlank(eventMeshServerRegistryEnableStr)) {
- eventMeshServerRegistryEnable = Boolean.valueOf(StringUtils.deleteWhitespace(eventMeshServerRegistryEnableStr));
+ eventMeshServerRegistryEnable =
+ Boolean.valueOf(StringUtils.deleteWhitespace(eventMeshServerRegistryEnableStr));
}
- eventMeshRegistryPluginType = configurationWrapper.getProp(ConfKeys.KEYS_ENENTMESH_REGISTRY_PLUGIN_TYPE);
- Preconditions.checkState(StringUtils.isNotEmpty(eventMeshRegistryPluginType), String.format("%s error", ConfKeys.KEYS_ENENTMESH_REGISTRY_PLUGIN_TYPE));
+ eventMeshRegistryPluginType =
+ configurationWrapper.getProp(ConfKeys.KEYS_ENENTMESH_REGISTRY_PLUGIN_TYPE);
+ Preconditions.checkState(StringUtils.isNotEmpty(eventMeshRegistryPluginType),
+ String.format("%s error", ConfKeys.KEYS_ENENTMESH_REGISTRY_PLUGIN_TYPE));
+
+ String eventMeshTraceExporterTypeStr =
+ configurationWrapper.getProp(ConfKeys.KEYS_ENENTMESH_TRACE_EXPORTER_TYPE);
+ Preconditions.checkState(StringUtils.isNotEmpty(eventMeshTraceExporterTypeStr),
+ String.format("%s error", ConfKeys.KEYS_ENENTMESH_TRACE_EXPORTER_TYPE));
+ eventMeshTraceExporterType =
+ StringUtils.deleteWhitespace(eventMeshTraceExporterTypeStr);
+
+ String eventMeshTraceExporterMaxExportSizeStr =
+ configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_TRACE_EXPORTER_MAX_EXPORT_SIZE);
+ if (StringUtils.isNotEmpty(eventMeshTraceExporterMaxExportSizeStr)) {
+ eventMeshTraceExporterMaxExportSize =
+ Integer.valueOf(StringUtils.deleteWhitespace(eventMeshTraceExporterMaxExportSizeStr));
+ }
+
+ String eventMeshTraceExporterMaxQueueSizeStr =
+ configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_TRACE_EXPORTER_MAX_QUEUE_SIZE);
+ if (StringUtils.isNotEmpty(eventMeshTraceExporterMaxQueueSizeStr)) {
+ eventMeshTraceExporterMaxQueueSize =
+ Integer.valueOf(StringUtils.deleteWhitespace(eventMeshTraceExporterMaxQueueSizeStr));
+ }
+
+ String eventMeshTraceExporterExportTimeoutStr =
+ configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_TRACE_EXPORTER_EXPORT_TIMEOUT);
+ if (StringUtils.isNotEmpty(eventMeshTraceExporterExportTimeoutStr)) {
+ eventMeshTraceExporterExportTimeout =
+ Integer.valueOf(StringUtils.deleteWhitespace(eventMeshTraceExporterExportTimeoutStr));
+ }
+
+ String eventMeshTraceExporterExportIntervalStr =
+ configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_TRACE_EXPORTER_EXPORT_INTERVAL);
+ if (StringUtils.isNotEmpty(eventMeshTraceExporterExportIntervalStr)) {
+ eventMeshTraceExporterExportInterval =
+ Integer.valueOf(StringUtils.deleteWhitespace(eventMeshTraceExporterExportIntervalStr));
+ }
+
+ String eventMeshTraceExportZipkinIpStr =
+ configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_TRACE_EXPORT_ZIPKIN_IP);
+ Preconditions.checkState(StringUtils.isNotEmpty(eventMeshTraceExportZipkinIpStr),
+ String.format("%s error", ConfKeys.KEYS_EVENTMESH_TRACE_EXPORT_ZIPKIN_IP));
+ eventMeshTraceExportZipkinIp = StringUtils.deleteWhitespace(eventMeshTraceExportZipkinIpStr);
+
+ String eventMeshTraceExportZipkinPortStr =
+ configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_TRACE_EXPORT_ZIPKIN_PORT);
+ if (StringUtils.isNotEmpty(eventMeshTraceExportZipkinPortStr)) {
+ eventMeshTraceExportZipkinPort =
+ Integer.valueOf(StringUtils.deleteWhitespace(eventMeshTraceExportZipkinPortStr));
+ }
}
}
@@ -112,9 +190,11 @@ static class ConfKeys {
public static String KEYS_EVENTMESH_SERVER_HOST_IP = "eventMesh.server.hostIp";
- public static String KEYS_EVENTMESH_SERVER_REGISTER_INTERVAL = "eventMesh.server.registry.registerIntervalInMills";
+ public static String KEYS_EVENTMESH_SERVER_REGISTER_INTERVAL =
+ "eventMesh.server.registry.registerIntervalInMills";
- public static String KEYS_EVENTMESH_SERVER_FETCH_REGISTRY_ADDR_INTERVAL = "eventMesh.server.registry.fetchRegistryAddrIntervalInMills";
+ public static String KEYS_EVENTMESH_SERVER_FETCH_REGISTRY_ADDR_INTERVAL =
+ "eventMesh.server.registry.fetchRegistryAddrIntervalInMills";
public static String KEYS_ENENTMESH_CONNECTOR_PLUGIN_TYPE = "eventMesh.connector.plugin.type";
@@ -127,5 +207,19 @@ static class ConfKeys {
public static String KEYS_EVENTMESH_REGISTRY_ENABLED = "eventMesh.server.registry.enabled";
public static String KEYS_ENENTMESH_REGISTRY_PLUGIN_TYPE = "eventMesh.registry.plugin.type";
+
+ public static String KEYS_ENENTMESH_TRACE_EXPORTER_TYPE = "eventmesh.trace.exporter.type";
+
+ public static String KEYS_EVENTMESH_TRACE_EXPORTER_MAX_EXPORT_SIZE = "eventmesh.trace.exporter.max.export.size";
+
+ public static String KEYS_EVENTMESH_TRACE_EXPORTER_MAX_QUEUE_SIZE = "eventmesh.trace.exporter.max.queue.size";
+
+ public static String KEYS_EVENTMESH_TRACE_EXPORTER_EXPORT_TIMEOUT = "eventmesh.trace.exporter.export.timeout";
+
+ public static String KEYS_EVENTMESH_TRACE_EXPORTER_EXPORT_INTERVAL = "eventmesh.trace.exporter.export.interval";
+
+ public static String KEYS_EVENTMESH_TRACE_EXPORT_ZIPKIN_IP = "eventmesh.trace.export.zipkin.ip";
+
+ public static String KEYS_EVENTMESH_TRACE_EXPORT_ZIPKIN_PORT = "eventmesh.trace.export.zipkin.port";
}
}
\ No newline at end of file
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshException.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/exception/EventMeshException.java
similarity index 87%
rename from eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshException.java
rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/exception/EventMeshException.java
index bffa57e780..9dc45c29f9 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshException.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/exception/EventMeshException.java
@@ -15,13 +15,10 @@
* limitations under the License.
*/
-package org.apache.eventmesh.common;
+package org.apache.eventmesh.common.exception;
public class EventMeshException extends Exception {
- public EventMeshException() {
- }
-
public EventMeshException(String message) {
super(message);
}
@@ -39,8 +36,6 @@ public EventMeshException(String message, Throwable cause, boolean enableSuppres
}
public EventMeshException(Integer errCode, String errMsg) {
- super((new StringBuilder()).append(errCode)
- .append("|")
- .append(errMsg).toString());
+ super(String.format("errorCode: %s, errorMessage: %s", errCode, errMsg));
}
}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/loadbalance/WeightRandomLoadBalanceSelector.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/loadbalance/WeightRandomLoadBalanceSelector.java
index 1fc239d608..835bc48382 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/loadbalance/WeightRandomLoadBalanceSelector.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/loadbalance/WeightRandomLoadBalanceSelector.java
@@ -19,7 +19,7 @@
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.RandomUtils;
-import org.apache.eventmesh.common.EventMeshException;
+import org.apache.eventmesh.common.exception.EventMeshException;
import java.util.List;
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/ProtocolTransportObject.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/ProtocolTransportObject.java
new file mode 100644
index 0000000000..ca7c36626a
--- /dev/null
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/ProtocolTransportObject.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.common.protocol;
+
+import org.apache.eventmesh.common.protocol.http.HttpCommand;
+
+import java.io.Serializable;
+
+/**
+ *
+ * Tcp transport object{@link org.apache.eventmesh.common.protocol.tcp.Package}
+ * Http transport object{@link HttpCommand}
+ *
+ */
+public interface ProtocolTransportObject extends Serializable {
+}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/EventMeshMessageWrapper.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/EventMeshMessageWrapper.java
new file mode 100644
index 0000000000..07bd66f968
--- /dev/null
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/EventMeshMessageWrapper.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.common.protocol.grpc.common;
+
+import org.apache.eventmesh.common.protocol.ProtocolTransportObject;
+import org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage;
+
+public class EventMeshMessageWrapper implements ProtocolTransportObject {
+
+ private EventMeshMessage eventMeshMessage;
+
+ public EventMeshMessageWrapper(EventMeshMessage eventMeshMessage) {
+ this.eventMeshMessage = eventMeshMessage;
+ }
+
+ public EventMeshMessage getMessage() {
+ return eventMeshMessage;
+ }
+}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/ProtocolKey.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/ProtocolKey.java
new file mode 100644
index 0000000000..62d171bc76
--- /dev/null
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/ProtocolKey.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.common.protocol.grpc.common;
+
+public class ProtocolKey {
+
+ public static final String ENV = "env";
+ public static final String IDC = "idc";
+ public static final String SYS = "sys";
+ public static final String PID = "pid";
+ public static final String IP = "ip";
+ public static final String USERNAME = "username";
+ public static final String PASSWD = "passwd";
+ public static final String LANGUAGE = "language";
+
+ public static final String PROTOCOL_TYPE = "protocoltype";
+ public static final String PROTOCOL_VERSION = "protocolversion";
+ public static final String PROTOCOL_DESC = "protocoldesc";
+
+ public static final String SEQ_NUM = "seqnum";
+ public static final String UNIQUE_ID = "uniqueid";
+ public static final String TTL = "ttl";
+ public static final String PRODUCERGROUP = "producergroup";
+ public static final String TAG = "tag";
+}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/StatusCode.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/StatusCode.java
new file mode 100644
index 0000000000..3b930e1803
--- /dev/null
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/common/StatusCode.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.common.protocol.grpc.common;
+
+public enum StatusCode {
+
+ SUCCESS("0", "success"),
+ OVERLOAD("1", "eventMesh overload, try later, "),
+ EVENTMESH_REQUESTCODE_INVALID("2", "requestCode can't be null, or must be number, "),
+ EVENTMESH_SEND_SYNC_MSG_ERR("3", "eventMesh send rr msg err, "),
+ EVENTMESH_WAITING_RR_MSG_ERR("4", "eventMesh waiting rr msg err, "),
+ EVENTMESH_PROTOCOL_HEADER_ERR("6", "eventMesh protocol[header] err, "),
+ EVENTMESH_PROTOCOL_BODY_ERR("7", "eventMesh protocol[body] err, "),
+ EVENTMESH_STOP("8", "eventMesh will stop or had stopped, "),
+ EVENTMESH_REJECT_BY_PROCESSOR_ERROR("9", "eventMesh reject by processor error, "),
+ EVENTMESH_BATCH_PRODUCER_STOPED_ERR("10", "eventMesh batch msg producer stopped, "),
+ EVENTMESH_SEND_BATCHLOG_MSG_ERR("17", "eventMesh send batchlog msg err, "),
+ EVENTMESH_BATCH_SPEED_OVER_LIMIT_ERR("11", "eventMesh batch msg speed over the limit, "),
+ EVENTMESH_PACKAGE_MSG_ERR("12", "eventMesh package msg err, "),
+ EVENTMESH_GROUP_PRODUCER_STOPED_ERR("13", "eventMesh group producer stopped, "),
+ EVENTMESH_SEND_ASYNC_MSG_ERR("14", "eventMesh send async msg err, "),
+ EVENTMESH_REPLY_MSG_ERR("15", "eventMesh reply msg err, "),
+ EVENTMESH_RUNTIME_ERR("16", "eventMesh runtime err, "),
+ EVENTMESH_SUBSCRIBE_ERR("17", "eventMesh subscribe err"),
+ EVENTMESH_UNSUBSCRIBE_ERR("18", "eventMesh unsubscribe err"),
+ EVENTMESH_HEARTBEAT_ERR("19", "eventMesh heartbeat err"),
+ EVENTMESH_ACL_ERR("20", "eventMesh acl err");
+
+ private String retCode;
+
+ private String errMsg;
+
+ StatusCode(String retCode, String errMsg) {
+ this.retCode = retCode;
+ this.errMsg = errMsg;
+ }
+
+ public String getRetCode() {
+ return retCode;
+ }
+
+ public void setRetCode(String retCode) {
+ this.retCode = retCode;
+ }
+
+ public String getErrMsg() {
+ return errMsg;
+ }
+
+ public void setErrMsg(String errMsg) {
+ this.errMsg = errMsg;
+ }
+}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java
new file mode 100644
index 0000000000..12454c8ab5
--- /dev/null
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ConsumerServiceGrpc.java
@@ -0,0 +1,423 @@
+package org.apache.eventmesh.common.protocol.grpc.protos;
+
+import static io.grpc.MethodDescriptor.generateFullMethodName;
+import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncUnaryCall;
+import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
+import static io.grpc.stub.ClientCalls.blockingUnaryCall;
+import static io.grpc.stub.ClientCalls.futureUnaryCall;
+import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncUnaryCall;
+import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
+
+/**
+ */
+@javax.annotation.Generated(
+ value = "by gRPC proto compiler (version 1.15.0)",
+ comments = "Source: eventmesh-client.proto")
+public final class ConsumerServiceGrpc {
+
+ private ConsumerServiceGrpc() {}
+
+ public static final String SERVICE_NAME = "eventmesh.common.protocol.grpc.ConsumerService";
+
+ // Static method descriptors that strictly reflect the proto.
+ private static volatile io.grpc.MethodDescriptor getSubscribeMethod;
+
+ @io.grpc.stub.annotations.RpcMethod(
+ fullMethodName = SERVICE_NAME + '/' + "subscribe",
+ requestType = Subscription.class,
+ responseType = Response.class,
+ methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
+ public static io.grpc.MethodDescriptor getSubscribeMethod() {
+ io.grpc.MethodDescriptor getSubscribeMethod;
+ if ((getSubscribeMethod = ConsumerServiceGrpc.getSubscribeMethod) == null) {
+ synchronized (ConsumerServiceGrpc.class) {
+ if ((getSubscribeMethod = ConsumerServiceGrpc.getSubscribeMethod) == null) {
+ ConsumerServiceGrpc.getSubscribeMethod = getSubscribeMethod =
+ io.grpc.MethodDescriptor.newBuilder()
+ .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName(generateFullMethodName(
+ "eventmesh.common.protocol.grpc.ConsumerService", "subscribe"))
+ .setSampledToLocalTracing(true)
+ .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+ Subscription.getDefaultInstance()))
+ .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+ Response.getDefaultInstance()))
+ .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("subscribe"))
+ .build();
+ }
+ }
+ }
+ return getSubscribeMethod;
+ }
+
+ private static volatile io.grpc.MethodDescriptor getSubscribeStreamMethod;
+
+ @io.grpc.stub.annotations.RpcMethod(
+ fullMethodName = SERVICE_NAME + '/' + "subscribeStream",
+ requestType = Subscription.class,
+ responseType = EventMeshMessage.class,
+ methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
+ public static io.grpc.MethodDescriptor getSubscribeStreamMethod() {
+ io.grpc.MethodDescriptor getSubscribeStreamMethod;
+ if ((getSubscribeStreamMethod = ConsumerServiceGrpc.getSubscribeStreamMethod) == null) {
+ synchronized (ConsumerServiceGrpc.class) {
+ if ((getSubscribeStreamMethod = ConsumerServiceGrpc.getSubscribeStreamMethod) == null) {
+ ConsumerServiceGrpc.getSubscribeStreamMethod = getSubscribeStreamMethod =
+ io.grpc.MethodDescriptor.newBuilder()
+ .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
+ .setFullMethodName(generateFullMethodName(
+ "eventmesh.common.protocol.grpc.ConsumerService", "subscribeStream"))
+ .setSampledToLocalTracing(true)
+ .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+ Subscription.getDefaultInstance()))
+ .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+ EventMeshMessage.getDefaultInstance()))
+ .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("subscribeStream"))
+ .build();
+ }
+ }
+ }
+ return getSubscribeStreamMethod;
+ }
+
+ private static volatile io.grpc.MethodDescriptor getUnsubscribeMethod;
+
+ @io.grpc.stub.annotations.RpcMethod(
+ fullMethodName = SERVICE_NAME + '/' + "unsubscribe",
+ requestType = Subscription.class,
+ responseType = Response.class,
+ methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
+ public static io.grpc.MethodDescriptor getUnsubscribeMethod() {
+ io.grpc.MethodDescriptor getUnsubscribeMethod;
+ if ((getUnsubscribeMethod = ConsumerServiceGrpc.getUnsubscribeMethod) == null) {
+ synchronized (ConsumerServiceGrpc.class) {
+ if ((getUnsubscribeMethod = ConsumerServiceGrpc.getUnsubscribeMethod) == null) {
+ ConsumerServiceGrpc.getUnsubscribeMethod = getUnsubscribeMethod =
+ io.grpc.MethodDescriptor.newBuilder()
+ .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName(generateFullMethodName(
+ "eventmesh.common.protocol.grpc.ConsumerService", "unsubscribe"))
+ .setSampledToLocalTracing(true)
+ .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+ Subscription.getDefaultInstance()))
+ .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+ Response.getDefaultInstance()))
+ .setSchemaDescriptor(new ConsumerServiceMethodDescriptorSupplier("unsubscribe"))
+ .build();
+ }
+ }
+ }
+ return getUnsubscribeMethod;
+ }
+
+ /**
+ * Creates a new async stub that supports all call types for the service
+ */
+ public static ConsumerServiceStub newStub(io.grpc.Channel channel) {
+ return new ConsumerServiceStub(channel);
+ }
+
+ /**
+ * Creates a new blocking-style stub that supports unary and streaming output calls on the service
+ */
+ public static ConsumerServiceBlockingStub newBlockingStub(
+ io.grpc.Channel channel) {
+ return new ConsumerServiceBlockingStub(channel);
+ }
+
+ /**
+ * Creates a new ListenableFuture-style stub that supports unary calls on the service
+ */
+ public static ConsumerServiceFutureStub newFutureStub(
+ io.grpc.Channel channel) {
+ return new ConsumerServiceFutureStub(channel);
+ }
+
+ /**
+ */
+ public static abstract class ConsumerServiceImplBase implements io.grpc.BindableService {
+
+ /**
+ */
+ public void subscribe(Subscription request,
+ io.grpc.stub.StreamObserver responseObserver) {
+ asyncUnimplementedUnaryCall(getSubscribeMethod(), responseObserver);
+ }
+
+ /**
+ */
+ public void subscribeStream(Subscription request,
+ io.grpc.stub.StreamObserver responseObserver) {
+ asyncUnimplementedUnaryCall(getSubscribeStreamMethod(), responseObserver);
+ }
+
+ /**
+ */
+ public void unsubscribe(Subscription request,
+ io.grpc.stub.StreamObserver responseObserver) {
+ asyncUnimplementedUnaryCall(getUnsubscribeMethod(), responseObserver);
+ }
+
+ @Override public final io.grpc.ServerServiceDefinition bindService() {
+ return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
+ .addMethod(
+ getSubscribeMethod(),
+ asyncUnaryCall(
+ new MethodHandlers<
+ Subscription,
+ Response>(
+ this, METHODID_SUBSCRIBE)))
+ .addMethod(
+ getSubscribeStreamMethod(),
+ asyncServerStreamingCall(
+ new MethodHandlers<
+ Subscription,
+ EventMeshMessage>(
+ this, METHODID_SUBSCRIBE_STREAM)))
+ .addMethod(
+ getUnsubscribeMethod(),
+ asyncUnaryCall(
+ new MethodHandlers<
+ Subscription,
+ Response>(
+ this, METHODID_UNSUBSCRIBE)))
+ .build();
+ }
+ }
+
+ /**
+ */
+ public static final class ConsumerServiceStub extends io.grpc.stub.AbstractStub {
+ private ConsumerServiceStub(io.grpc.Channel channel) {
+ super(channel);
+ }
+
+ private ConsumerServiceStub(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ super(channel, callOptions);
+ }
+
+ @Override
+ protected ConsumerServiceStub build(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ return new ConsumerServiceStub(channel, callOptions);
+ }
+
+ /**
+ */
+ public void subscribe(Subscription request,
+ io.grpc.stub.StreamObserver responseObserver) {
+ asyncUnaryCall(
+ getChannel().newCall(getSubscribeMethod(), getCallOptions()), request, responseObserver);
+ }
+
+ /**
+ */
+ public void subscribeStream(Subscription request,
+ io.grpc.stub.StreamObserver responseObserver) {
+ asyncServerStreamingCall(
+ getChannel().newCall(getSubscribeStreamMethod(), getCallOptions()), request, responseObserver);
+ }
+
+ /**
+ */
+ public void unsubscribe(Subscription request,
+ io.grpc.stub.StreamObserver responseObserver) {
+ asyncUnaryCall(
+ getChannel().newCall(getUnsubscribeMethod(), getCallOptions()), request, responseObserver);
+ }
+ }
+
+ /**
+ */
+ public static final class ConsumerServiceBlockingStub extends io.grpc.stub.AbstractStub {
+ private ConsumerServiceBlockingStub(io.grpc.Channel channel) {
+ super(channel);
+ }
+
+ private ConsumerServiceBlockingStub(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ super(channel, callOptions);
+ }
+
+ @Override
+ protected ConsumerServiceBlockingStub build(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ return new ConsumerServiceBlockingStub(channel, callOptions);
+ }
+
+ /**
+ */
+ public Response subscribe(Subscription request) {
+ return blockingUnaryCall(
+ getChannel(), getSubscribeMethod(), getCallOptions(), request);
+ }
+
+ /**
+ */
+ public java.util.Iterator subscribeStream(
+ Subscription request) {
+ return blockingServerStreamingCall(
+ getChannel(), getSubscribeStreamMethod(), getCallOptions(), request);
+ }
+
+ /**
+ */
+ public Response unsubscribe(Subscription request) {
+ return blockingUnaryCall(
+ getChannel(), getUnsubscribeMethod(), getCallOptions(), request);
+ }
+ }
+
+ /**
+ */
+ public static final class ConsumerServiceFutureStub extends io.grpc.stub.AbstractStub {
+ private ConsumerServiceFutureStub(io.grpc.Channel channel) {
+ super(channel);
+ }
+
+ private ConsumerServiceFutureStub(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ super(channel, callOptions);
+ }
+
+ @Override
+ protected ConsumerServiceFutureStub build(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ return new ConsumerServiceFutureStub(channel, callOptions);
+ }
+
+ /**
+ */
+ public com.google.common.util.concurrent.ListenableFuture subscribe(
+ Subscription request) {
+ return futureUnaryCall(
+ getChannel().newCall(getSubscribeMethod(), getCallOptions()), request);
+ }
+
+ /**
+ */
+ public com.google.common.util.concurrent.ListenableFuture unsubscribe(
+ Subscription request) {
+ return futureUnaryCall(
+ getChannel().newCall(getUnsubscribeMethod(), getCallOptions()), request);
+ }
+ }
+
+ private static final int METHODID_SUBSCRIBE = 0;
+ private static final int METHODID_SUBSCRIBE_STREAM = 1;
+ private static final int METHODID_UNSUBSCRIBE = 2;
+
+ private static final class MethodHandlers implements
+ io.grpc.stub.ServerCalls.UnaryMethod,
+ io.grpc.stub.ServerCalls.ServerStreamingMethod,
+ io.grpc.stub.ServerCalls.ClientStreamingMethod,
+ io.grpc.stub.ServerCalls.BidiStreamingMethod {
+ private final ConsumerServiceImplBase serviceImpl;
+ private final int methodId;
+
+ MethodHandlers(ConsumerServiceImplBase serviceImpl, int methodId) {
+ this.serviceImpl = serviceImpl;
+ this.methodId = methodId;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) {
+ switch (methodId) {
+ case METHODID_SUBSCRIBE:
+ serviceImpl.subscribe((Subscription) request,
+ (io.grpc.stub.StreamObserver) responseObserver);
+ break;
+ case METHODID_SUBSCRIBE_STREAM:
+ serviceImpl.subscribeStream((Subscription) request,
+ (io.grpc.stub.StreamObserver) responseObserver);
+ break;
+ case METHODID_UNSUBSCRIBE:
+ serviceImpl.unsubscribe((Subscription) request,
+ (io.grpc.stub.StreamObserver) responseObserver);
+ break;
+ default:
+ throw new AssertionError();
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public io.grpc.stub.StreamObserver invoke(
+ io.grpc.stub.StreamObserver responseObserver) {
+ switch (methodId) {
+ default:
+ throw new AssertionError();
+ }
+ }
+ }
+
+ private static abstract class ConsumerServiceBaseDescriptorSupplier
+ implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
+ ConsumerServiceBaseDescriptorSupplier() {}
+
+ @Override
+ public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
+ return EventmeshGrpc.getDescriptor();
+ }
+
+ @Override
+ public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
+ return getFileDescriptor().findServiceByName("ConsumerService");
+ }
+ }
+
+ private static final class ConsumerServiceFileDescriptorSupplier
+ extends ConsumerServiceBaseDescriptorSupplier {
+ ConsumerServiceFileDescriptorSupplier() {}
+ }
+
+ private static final class ConsumerServiceMethodDescriptorSupplier
+ extends ConsumerServiceBaseDescriptorSupplier
+ implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
+ private final String methodName;
+
+ ConsumerServiceMethodDescriptorSupplier(String methodName) {
+ this.methodName = methodName;
+ }
+
+ @Override
+ public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
+ return getServiceDescriptor().findMethodByName(methodName);
+ }
+ }
+
+ private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
+
+ public static io.grpc.ServiceDescriptor getServiceDescriptor() {
+ io.grpc.ServiceDescriptor result = serviceDescriptor;
+ if (result == null) {
+ synchronized (ConsumerServiceGrpc.class) {
+ result = serviceDescriptor;
+ if (result == null) {
+ serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
+ .setSchemaDescriptor(new ConsumerServiceFileDescriptorSupplier())
+ .addMethod(getSubscribeMethod())
+ .addMethod(getSubscribeStreamMethod())
+ .addMethod(getUnsubscribeMethod())
+ .build();
+ }
+ }
+ }
+ return result;
+ }
+}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java
new file mode 100644
index 0000000000..c36fa52ee7
--- /dev/null
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessage.java
@@ -0,0 +1,1459 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: eventmesh-client.proto
+
+package org.apache.eventmesh.common.protocol.grpc.protos;
+
+/**
+ * Protobuf type {@code eventmesh.common.protocol.grpc.EventMeshMessage}
+ */
+public final class EventMeshMessage extends
+ com.google.protobuf.GeneratedMessageV3 implements
+ // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.EventMeshMessage)
+ EventMeshMessageOrBuilder {
+private static final long serialVersionUID = 0L;
+ // Use EventMeshMessage.newBuilder() to construct.
+ private EventMeshMessage(com.google.protobuf.GeneratedMessageV3.Builder> builder) {
+ super(builder);
+ }
+ private EventMeshMessage() {
+ producerGroup_ = "";
+ topic_ = "";
+ content_ = "";
+ ttl_ = "";
+ uniqueId_ = "";
+ seqNum_ = "";
+ tag_ = "";
+ }
+
+ @Override
+ public final com.google.protobuf.UnknownFieldSet
+ getUnknownFields() {
+ return this.unknownFields;
+ }
+ private EventMeshMessage(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ this();
+ if (extensionRegistry == null) {
+ throw new NullPointerException();
+ }
+ int mutable_bitField0_ = 0;
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder();
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ default: {
+ if (!parseUnknownFieldProto3(
+ input, unknownFields, extensionRegistry, tag)) {
+ done = true;
+ }
+ break;
+ }
+ case 10: {
+ RequestHeader.Builder subBuilder = null;
+ if (header_ != null) {
+ subBuilder = header_.toBuilder();
+ }
+ header_ = input.readMessage(RequestHeader.parser(), extensionRegistry);
+ if (subBuilder != null) {
+ subBuilder.mergeFrom(header_);
+ header_ = subBuilder.buildPartial();
+ }
+
+ break;
+ }
+ case 18: {
+ String s = input.readStringRequireUtf8();
+
+ producerGroup_ = s;
+ break;
+ }
+ case 26: {
+ String s = input.readStringRequireUtf8();
+
+ topic_ = s;
+ break;
+ }
+ case 34: {
+ String s = input.readStringRequireUtf8();
+
+ content_ = s;
+ break;
+ }
+ case 42: {
+ String s = input.readStringRequireUtf8();
+
+ ttl_ = s;
+ break;
+ }
+ case 50: {
+ String s = input.readStringRequireUtf8();
+
+ uniqueId_ = s;
+ break;
+ }
+ case 58: {
+ String s = input.readStringRequireUtf8();
+
+ seqNum_ = s;
+ break;
+ }
+ case 66: {
+ String s = input.readStringRequireUtf8();
+
+ tag_ = s;
+ break;
+ }
+ }
+ }
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(this);
+ } catch (java.io.IOException e) {
+ throw new com.google.protobuf.InvalidProtocolBufferException(
+ e).setUnfinishedMessage(this);
+ } finally {
+ this.unknownFields = unknownFields.build();
+ makeExtensionsImmutable();
+ }
+ }
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor;
+ }
+
+ protected FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ EventMeshMessage.class, Builder.class);
+ }
+
+ public static final int HEADER_FIELD_NUMBER = 1;
+ private RequestHeader header_;
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public boolean hasHeader() {
+ return header_ != null;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public RequestHeader getHeader() {
+ return header_ == null ? RequestHeader.getDefaultInstance() : header_;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public RequestHeaderOrBuilder getHeaderOrBuilder() {
+ return getHeader();
+ }
+
+ public static final int PRODUCERGROUP_FIELD_NUMBER = 2;
+ private volatile Object producerGroup_;
+ /**
+ * string producerGroup = 2;
+ */
+ public String getProducerGroup() {
+ Object ref = producerGroup_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ producerGroup_ = s;
+ return s;
+ }
+ }
+ /**
+ * string producerGroup = 2;
+ */
+ public com.google.protobuf.ByteString
+ getProducerGroupBytes() {
+ Object ref = producerGroup_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ producerGroup_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int TOPIC_FIELD_NUMBER = 3;
+ private volatile Object topic_;
+ /**
+ * string topic = 3;
+ */
+ public String getTopic() {
+ Object ref = topic_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ topic_ = s;
+ return s;
+ }
+ }
+ /**
+ * string topic = 3;
+ */
+ public com.google.protobuf.ByteString
+ getTopicBytes() {
+ Object ref = topic_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ topic_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int CONTENT_FIELD_NUMBER = 4;
+ private volatile Object content_;
+ /**
+ * string content = 4;
+ */
+ public String getContent() {
+ Object ref = content_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ content_ = s;
+ return s;
+ }
+ }
+ /**
+ * string content = 4;
+ */
+ public com.google.protobuf.ByteString
+ getContentBytes() {
+ Object ref = content_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ content_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int TTL_FIELD_NUMBER = 5;
+ private volatile Object ttl_;
+ /**
+ * string ttl = 5;
+ */
+ public String getTtl() {
+ Object ref = ttl_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ ttl_ = s;
+ return s;
+ }
+ }
+ /**
+ * string ttl = 5;
+ */
+ public com.google.protobuf.ByteString
+ getTtlBytes() {
+ Object ref = ttl_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ ttl_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int UNIQUEID_FIELD_NUMBER = 6;
+ private volatile Object uniqueId_;
+ /**
+ * string uniqueId = 6;
+ */
+ public String getUniqueId() {
+ Object ref = uniqueId_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ uniqueId_ = s;
+ return s;
+ }
+ }
+ /**
+ * string uniqueId = 6;
+ */
+ public com.google.protobuf.ByteString
+ getUniqueIdBytes() {
+ Object ref = uniqueId_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ uniqueId_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int SEQNUM_FIELD_NUMBER = 7;
+ private volatile Object seqNum_;
+ /**
+ * string seqNum = 7;
+ */
+ public String getSeqNum() {
+ Object ref = seqNum_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ seqNum_ = s;
+ return s;
+ }
+ }
+ /**
+ * string seqNum = 7;
+ */
+ public com.google.protobuf.ByteString
+ getSeqNumBytes() {
+ Object ref = seqNum_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ seqNum_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int TAG_FIELD_NUMBER = 8;
+ private volatile Object tag_;
+ /**
+ * string tag = 8;
+ */
+ public String getTag() {
+ Object ref = tag_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ tag_ = s;
+ return s;
+ }
+ }
+ /**
+ * string tag = 8;
+ */
+ public com.google.protobuf.ByteString
+ getTagBytes() {
+ Object ref = tag_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ tag_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized == 1) return true;
+ if (isInitialized == 0) return false;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ if (header_ != null) {
+ output.writeMessage(1, getHeader());
+ }
+ if (!getProducerGroupBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 2, producerGroup_);
+ }
+ if (!getTopicBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 3, topic_);
+ }
+ if (!getContentBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 4, content_);
+ }
+ if (!getTtlBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 5, ttl_);
+ }
+ if (!getUniqueIdBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 6, uniqueId_);
+ }
+ if (!getSeqNumBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 7, seqNum_);
+ }
+ if (!getTagBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 8, tag_);
+ }
+ unknownFields.writeTo(output);
+ }
+
+ public int getSerializedSize() {
+ int size = memoizedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (header_ != null) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeMessageSize(1, getHeader());
+ }
+ if (!getProducerGroupBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, producerGroup_);
+ }
+ if (!getTopicBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, topic_);
+ }
+ if (!getContentBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, content_);
+ }
+ if (!getTtlBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, ttl_);
+ }
+ if (!getUniqueIdBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, uniqueId_);
+ }
+ if (!getSeqNumBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, seqNum_);
+ }
+ if (!getTagBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, tag_);
+ }
+ size += unknownFields.getSerializedSize();
+ memoizedSize = size;
+ return size;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof EventMeshMessage)) {
+ return super.equals(obj);
+ }
+ EventMeshMessage other = (EventMeshMessage) obj;
+
+ boolean result = true;
+ result = result && (hasHeader() == other.hasHeader());
+ if (hasHeader()) {
+ result = result && getHeader()
+ .equals(other.getHeader());
+ }
+ result = result && getProducerGroup()
+ .equals(other.getProducerGroup());
+ result = result && getTopic()
+ .equals(other.getTopic());
+ result = result && getContent()
+ .equals(other.getContent());
+ result = result && getTtl()
+ .equals(other.getTtl());
+ result = result && getUniqueId()
+ .equals(other.getUniqueId());
+ result = result && getSeqNum()
+ .equals(other.getSeqNum());
+ result = result && getTag()
+ .equals(other.getTag());
+ result = result && unknownFields.equals(other.unknownFields);
+ return result;
+ }
+
+ @Override
+ public int hashCode() {
+ if (memoizedHashCode != 0) {
+ return memoizedHashCode;
+ }
+ int hash = 41;
+ hash = (19 * hash) + getDescriptor().hashCode();
+ if (hasHeader()) {
+ hash = (37 * hash) + HEADER_FIELD_NUMBER;
+ hash = (53 * hash) + getHeader().hashCode();
+ }
+ hash = (37 * hash) + PRODUCERGROUP_FIELD_NUMBER;
+ hash = (53 * hash) + getProducerGroup().hashCode();
+ hash = (37 * hash) + TOPIC_FIELD_NUMBER;
+ hash = (53 * hash) + getTopic().hashCode();
+ hash = (37 * hash) + CONTENT_FIELD_NUMBER;
+ hash = (53 * hash) + getContent().hashCode();
+ hash = (37 * hash) + TTL_FIELD_NUMBER;
+ hash = (53 * hash) + getTtl().hashCode();
+ hash = (37 * hash) + UNIQUEID_FIELD_NUMBER;
+ hash = (53 * hash) + getUniqueId().hashCode();
+ hash = (37 * hash) + SEQNUM_FIELD_NUMBER;
+ hash = (53 * hash) + getSeqNum().hashCode();
+ hash = (37 * hash) + TAG_FIELD_NUMBER;
+ hash = (53 * hash) + getTag().hashCode();
+ hash = (29 * hash) + unknownFields.hashCode();
+ memoizedHashCode = hash;
+ return hash;
+ }
+
+ public static EventMeshMessage parseFrom(
+ java.nio.ByteBuffer data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static EventMeshMessage parseFrom(
+ java.nio.ByteBuffer data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static EventMeshMessage parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static EventMeshMessage parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static EventMeshMessage parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static EventMeshMessage parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static EventMeshMessage parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static EventMeshMessage parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static EventMeshMessage parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input);
+ }
+ public static EventMeshMessage parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static EventMeshMessage parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static EventMeshMessage parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder() {
+ return DEFAULT_INSTANCE.toBuilder();
+ }
+ public static Builder newBuilder(EventMeshMessage prototype) {
+ return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() {
+ return this == DEFAULT_INSTANCE
+ ? new Builder() : new Builder().mergeFrom(this);
+ }
+
+ @Override
+ protected Builder newBuilderForType(
+ BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ * Protobuf type {@code eventmesh.common.protocol.grpc.EventMeshMessage}
+ */
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessageV3.Builder implements
+ // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.EventMeshMessage)
+ EventMeshMessageOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor;
+ }
+
+ protected FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ EventMeshMessage.class, Builder.class);
+ }
+
+ // Construct using org.apache.eventmesh.common.protocol.grpc.protos.EventMeshMessage.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(
+ BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessageV3
+ .alwaysUseFieldBuilders) {
+ }
+ }
+ public Builder clear() {
+ super.clear();
+ if (headerBuilder_ == null) {
+ header_ = null;
+ } else {
+ header_ = null;
+ headerBuilder_ = null;
+ }
+ producerGroup_ = "";
+
+ topic_ = "";
+
+ content_ = "";
+
+ ttl_ = "";
+
+ uniqueId_ = "";
+
+ seqNum_ = "";
+
+ tag_ = "";
+
+ return this;
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor;
+ }
+
+ public EventMeshMessage getDefaultInstanceForType() {
+ return EventMeshMessage.getDefaultInstance();
+ }
+
+ public EventMeshMessage build() {
+ EventMeshMessage result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ public EventMeshMessage buildPartial() {
+ EventMeshMessage result = new EventMeshMessage(this);
+ if (headerBuilder_ == null) {
+ result.header_ = header_;
+ } else {
+ result.header_ = headerBuilder_.build();
+ }
+ result.producerGroup_ = producerGroup_;
+ result.topic_ = topic_;
+ result.content_ = content_;
+ result.ttl_ = ttl_;
+ result.uniqueId_ = uniqueId_;
+ result.seqNum_ = seqNum_;
+ result.tag_ = tag_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder clone() {
+ return (Builder) super.clone();
+ }
+ public Builder setField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ Object value) {
+ return (Builder) super.setField(field, value);
+ }
+ public Builder clearField(
+ com.google.protobuf.Descriptors.FieldDescriptor field) {
+ return (Builder) super.clearField(field);
+ }
+ public Builder clearOneof(
+ com.google.protobuf.Descriptors.OneofDescriptor oneof) {
+ return (Builder) super.clearOneof(oneof);
+ }
+ public Builder setRepeatedField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ int index, Object value) {
+ return (Builder) super.setRepeatedField(field, index, value);
+ }
+ public Builder addRepeatedField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ Object value) {
+ return (Builder) super.addRepeatedField(field, value);
+ }
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof EventMeshMessage) {
+ return mergeFrom((EventMeshMessage)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(EventMeshMessage other) {
+ if (other == EventMeshMessage.getDefaultInstance()) return this;
+ if (other.hasHeader()) {
+ mergeHeader(other.getHeader());
+ }
+ if (!other.getProducerGroup().isEmpty()) {
+ producerGroup_ = other.producerGroup_;
+ onChanged();
+ }
+ if (!other.getTopic().isEmpty()) {
+ topic_ = other.topic_;
+ onChanged();
+ }
+ if (!other.getContent().isEmpty()) {
+ content_ = other.content_;
+ onChanged();
+ }
+ if (!other.getTtl().isEmpty()) {
+ ttl_ = other.ttl_;
+ onChanged();
+ }
+ if (!other.getUniqueId().isEmpty()) {
+ uniqueId_ = other.uniqueId_;
+ onChanged();
+ }
+ if (!other.getSeqNum().isEmpty()) {
+ seqNum_ = other.seqNum_;
+ onChanged();
+ }
+ if (!other.getTag().isEmpty()) {
+ tag_ = other.tag_;
+ onChanged();
+ }
+ this.mergeUnknownFields(other.unknownFields);
+ onChanged();
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ EventMeshMessage parsedMessage = null;
+ try {
+ parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ parsedMessage = (EventMeshMessage) e.getUnfinishedMessage();
+ throw e.unwrapIOException();
+ } finally {
+ if (parsedMessage != null) {
+ mergeFrom(parsedMessage);
+ }
+ }
+ return this;
+ }
+
+ private RequestHeader header_ = null;
+ private com.google.protobuf.SingleFieldBuilderV3<
+ RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> headerBuilder_;
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public boolean hasHeader() {
+ return headerBuilder_ != null || header_ != null;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public RequestHeader getHeader() {
+ if (headerBuilder_ == null) {
+ return header_ == null ? RequestHeader.getDefaultInstance() : header_;
+ } else {
+ return headerBuilder_.getMessage();
+ }
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public Builder setHeader(RequestHeader value) {
+ if (headerBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ header_ = value;
+ onChanged();
+ } else {
+ headerBuilder_.setMessage(value);
+ }
+
+ return this;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public Builder setHeader(
+ RequestHeader.Builder builderForValue) {
+ if (headerBuilder_ == null) {
+ header_ = builderForValue.build();
+ onChanged();
+ } else {
+ headerBuilder_.setMessage(builderForValue.build());
+ }
+
+ return this;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public Builder mergeHeader(RequestHeader value) {
+ if (headerBuilder_ == null) {
+ if (header_ != null) {
+ header_ =
+ RequestHeader.newBuilder(header_).mergeFrom(value).buildPartial();
+ } else {
+ header_ = value;
+ }
+ onChanged();
+ } else {
+ headerBuilder_.mergeFrom(value);
+ }
+
+ return this;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public Builder clearHeader() {
+ if (headerBuilder_ == null) {
+ header_ = null;
+ onChanged();
+ } else {
+ header_ = null;
+ headerBuilder_ = null;
+ }
+
+ return this;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public RequestHeader.Builder getHeaderBuilder() {
+
+ onChanged();
+ return getHeaderFieldBuilder().getBuilder();
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public RequestHeaderOrBuilder getHeaderOrBuilder() {
+ if (headerBuilder_ != null) {
+ return headerBuilder_.getMessageOrBuilder();
+ } else {
+ return header_ == null ?
+ RequestHeader.getDefaultInstance() : header_;
+ }
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ private com.google.protobuf.SingleFieldBuilderV3<
+ RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>
+ getHeaderFieldBuilder() {
+ if (headerBuilder_ == null) {
+ headerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
+ RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>(
+ getHeader(),
+ getParentForChildren(),
+ isClean());
+ header_ = null;
+ }
+ return headerBuilder_;
+ }
+
+ private Object producerGroup_ = "";
+ /**
+ * string producerGroup = 2;
+ */
+ public String getProducerGroup() {
+ Object ref = producerGroup_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ producerGroup_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string producerGroup = 2;
+ */
+ public com.google.protobuf.ByteString
+ getProducerGroupBytes() {
+ Object ref = producerGroup_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ producerGroup_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string producerGroup = 2;
+ */
+ public Builder setProducerGroup(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ producerGroup_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string producerGroup = 2;
+ */
+ public Builder clearProducerGroup() {
+
+ producerGroup_ = getDefaultInstance().getProducerGroup();
+ onChanged();
+ return this;
+ }
+ /**
+ * string producerGroup = 2;
+ */
+ public Builder setProducerGroupBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ producerGroup_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object topic_ = "";
+ /**
+ * string topic = 3;
+ */
+ public String getTopic() {
+ Object ref = topic_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ topic_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string topic = 3;
+ */
+ public com.google.protobuf.ByteString
+ getTopicBytes() {
+ Object ref = topic_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ topic_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string topic = 3;
+ */
+ public Builder setTopic(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ topic_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string topic = 3;
+ */
+ public Builder clearTopic() {
+
+ topic_ = getDefaultInstance().getTopic();
+ onChanged();
+ return this;
+ }
+ /**
+ * string topic = 3;
+ */
+ public Builder setTopicBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ topic_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object content_ = "";
+ /**
+ * string content = 4;
+ */
+ public String getContent() {
+ Object ref = content_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ content_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string content = 4;
+ */
+ public com.google.protobuf.ByteString
+ getContentBytes() {
+ Object ref = content_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ content_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string content = 4;
+ */
+ public Builder setContent(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ content_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string content = 4;
+ */
+ public Builder clearContent() {
+
+ content_ = getDefaultInstance().getContent();
+ onChanged();
+ return this;
+ }
+ /**
+ * string content = 4;
+ */
+ public Builder setContentBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ content_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object ttl_ = "";
+ /**
+ * string ttl = 5;
+ */
+ public String getTtl() {
+ Object ref = ttl_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ ttl_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string ttl = 5;
+ */
+ public com.google.protobuf.ByteString
+ getTtlBytes() {
+ Object ref = ttl_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ ttl_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string ttl = 5;
+ */
+ public Builder setTtl(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ ttl_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string ttl = 5;
+ */
+ public Builder clearTtl() {
+
+ ttl_ = getDefaultInstance().getTtl();
+ onChanged();
+ return this;
+ }
+ /**
+ * string ttl = 5;
+ */
+ public Builder setTtlBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ ttl_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object uniqueId_ = "";
+ /**
+ * string uniqueId = 6;
+ */
+ public String getUniqueId() {
+ Object ref = uniqueId_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ uniqueId_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string uniqueId = 6;
+ */
+ public com.google.protobuf.ByteString
+ getUniqueIdBytes() {
+ Object ref = uniqueId_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ uniqueId_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string uniqueId = 6;
+ */
+ public Builder setUniqueId(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ uniqueId_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string uniqueId = 6;
+ */
+ public Builder clearUniqueId() {
+
+ uniqueId_ = getDefaultInstance().getUniqueId();
+ onChanged();
+ return this;
+ }
+ /**
+ * string uniqueId = 6;
+ */
+ public Builder setUniqueIdBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ uniqueId_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object seqNum_ = "";
+ /**
+ * string seqNum = 7;
+ */
+ public String getSeqNum() {
+ Object ref = seqNum_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ seqNum_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string seqNum = 7;
+ */
+ public com.google.protobuf.ByteString
+ getSeqNumBytes() {
+ Object ref = seqNum_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ seqNum_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string seqNum = 7;
+ */
+ public Builder setSeqNum(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ seqNum_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string seqNum = 7;
+ */
+ public Builder clearSeqNum() {
+
+ seqNum_ = getDefaultInstance().getSeqNum();
+ onChanged();
+ return this;
+ }
+ /**
+ * string seqNum = 7;
+ */
+ public Builder setSeqNumBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ seqNum_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object tag_ = "";
+ /**
+ * string tag = 8;
+ */
+ public String getTag() {
+ Object ref = tag_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ tag_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string tag = 8;
+ */
+ public com.google.protobuf.ByteString
+ getTagBytes() {
+ Object ref = tag_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ tag_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string tag = 8;
+ */
+ public Builder setTag(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ tag_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string tag = 8;
+ */
+ public Builder clearTag() {
+
+ tag_ = getDefaultInstance().getTag();
+ onChanged();
+ return this;
+ }
+ /**
+ * string tag = 8;
+ */
+ public Builder setTagBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ tag_ = value;
+ onChanged();
+ return this;
+ }
+ public final Builder setUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.setUnknownFieldsProto3(unknownFields);
+ }
+
+ public final Builder mergeUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.mergeUnknownFields(unknownFields);
+ }
+
+
+ // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.EventMeshMessage)
+ }
+
+ // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.EventMeshMessage)
+ private static final EventMeshMessage DEFAULT_INSTANCE;
+ static {
+ DEFAULT_INSTANCE = new EventMeshMessage();
+ }
+
+ public static EventMeshMessage getDefaultInstance() {
+ return DEFAULT_INSTANCE;
+ }
+
+ private static final com.google.protobuf.Parser
+ PARSER = new com.google.protobuf.AbstractParser() {
+ public EventMeshMessage parsePartialFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return new EventMeshMessage(input, extensionRegistry);
+ }
+ };
+
+ public static com.google.protobuf.Parser parser() {
+ return PARSER;
+ }
+
+ @Override
+ public com.google.protobuf.Parser getParserForType() {
+ return PARSER;
+ }
+
+ public EventMeshMessage getDefaultInstanceForType() {
+ return DEFAULT_INSTANCE;
+ }
+
+}
+
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java
new file mode 100644
index 0000000000..505bbdd1cc
--- /dev/null
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventMeshMessageOrBuilder.java
@@ -0,0 +1,92 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: eventmesh-client.proto
+
+package org.apache.eventmesh.common.protocol.grpc.protos;
+
+public interface EventMeshMessageOrBuilder extends
+ // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.EventMeshMessage)
+ com.google.protobuf.MessageOrBuilder {
+
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ boolean hasHeader();
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ RequestHeader getHeader();
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ RequestHeaderOrBuilder getHeaderOrBuilder();
+
+ /**
+ * string producerGroup = 2;
+ */
+ String getProducerGroup();
+ /**
+ * string producerGroup = 2;
+ */
+ com.google.protobuf.ByteString
+ getProducerGroupBytes();
+
+ /**
+ * string topic = 3;
+ */
+ String getTopic();
+ /**
+ * string topic = 3;
+ */
+ com.google.protobuf.ByteString
+ getTopicBytes();
+
+ /**
+ * string content = 4;
+ */
+ String getContent();
+ /**
+ * string content = 4;
+ */
+ com.google.protobuf.ByteString
+ getContentBytes();
+
+ /**
+ * string ttl = 5;
+ */
+ String getTtl();
+ /**
+ * string ttl = 5;
+ */
+ com.google.protobuf.ByteString
+ getTtlBytes();
+
+ /**
+ * string uniqueId = 6;
+ */
+ String getUniqueId();
+ /**
+ * string uniqueId = 6;
+ */
+ com.google.protobuf.ByteString
+ getUniqueIdBytes();
+
+ /**
+ * string seqNum = 7;
+ */
+ String getSeqNum();
+ /**
+ * string seqNum = 7;
+ */
+ com.google.protobuf.ByteString
+ getSeqNumBytes();
+
+ /**
+ * string tag = 8;
+ */
+ String getTag();
+ /**
+ * string tag = 8;
+ */
+ com.google.protobuf.ByteString
+ getTagBytes();
+}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java
new file mode 100644
index 0000000000..2506c9bfbd
--- /dev/null
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/EventmeshGrpc.java
@@ -0,0 +1,177 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: eventmesh-client.proto
+
+package org.apache.eventmesh.common.protocol.grpc.protos;
+
+public final class EventmeshGrpc {
+ private EventmeshGrpc() {}
+ public static void registerAllExtensions(
+ com.google.protobuf.ExtensionRegistryLite registry) {
+ }
+
+ public static void registerAllExtensions(
+ com.google.protobuf.ExtensionRegistry registry) {
+ registerAllExtensions(
+ (com.google.protobuf.ExtensionRegistryLite) registry);
+ }
+ static final com.google.protobuf.Descriptors.Descriptor
+ internal_static_eventmesh_common_protocol_grpc_RequestHeader_descriptor;
+ static final
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internal_static_eventmesh_common_protocol_grpc_RequestHeader_fieldAccessorTable;
+ static final com.google.protobuf.Descriptors.Descriptor
+ internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor;
+ static final
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_fieldAccessorTable;
+ static final com.google.protobuf.Descriptors.Descriptor
+ internal_static_eventmesh_common_protocol_grpc_Response_descriptor;
+ static final
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internal_static_eventmesh_common_protocol_grpc_Response_fieldAccessorTable;
+ static final com.google.protobuf.Descriptors.Descriptor
+ internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor;
+ static final
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internal_static_eventmesh_common_protocol_grpc_Subscription_fieldAccessorTable;
+ static final com.google.protobuf.Descriptors.Descriptor
+ internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor;
+ static final
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_fieldAccessorTable;
+ static final com.google.protobuf.Descriptors.Descriptor
+ internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor;
+ static final
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internal_static_eventmesh_common_protocol_grpc_Heartbeat_fieldAccessorTable;
+ static final com.google.protobuf.Descriptors.Descriptor
+ internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_descriptor;
+ static final
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_fieldAccessorTable;
+
+ public static com.google.protobuf.Descriptors.FileDescriptor
+ getDescriptor() {
+ return descriptor;
+ }
+ private static com.google.protobuf.Descriptors.FileDescriptor
+ descriptor;
+ static {
+ String[] descriptorData = {
+ "\n\026eventmesh-client.proto\022\036eventmesh.comm" +
+ "on.protocol.grpc\"\332\001\n\rRequestHeader\022\013\n\003en" +
+ "v\030\001 \001(\t\022\016\n\006region\030\002 \001(\t\022\013\n\003idc\030\003 \001(\t\022\n\n\002" +
+ "ip\030\004 \001(\t\022\013\n\003pid\030\005 \001(\t\022\013\n\003sys\030\006 \001(\t\022\020\n\010us" +
+ "ername\030\007 \001(\t\022\020\n\010password\030\010 \001(\t\022\020\n\010langua" +
+ "ge\030\t \001(\t\022\024\n\014protocolType\030\n \001(\t\022\027\n\017protoc" +
+ "olVersion\030\013 \001(\t\022\024\n\014protocolDesc\030\014 \001(\t\"\304\001" +
+ "\n\020EventMeshMessage\022=\n\006header\030\001 \001(\0132-.eve" +
+ "ntmesh.common.protocol.grpc.RequestHeade" +
+ "r\022\025\n\rproducerGroup\030\002 \001(\t\022\r\n\005topic\030\003 \001(\t\022" +
+ "\017\n\007content\030\004 \001(\t\022\013\n\003ttl\030\005 \001(\t\022\020\n\010uniqueI" +
+ "d\030\006 \001(\t\022\016\n\006seqNum\030\007 \001(\t\022\013\n\003tag\030\010 \001(\t\"O\n\010" +
+ "Response\022\020\n\010respCode\030\001 \001(\t\022\017\n\007respMsg\030\002 " +
+ "\001(\t\022\020\n\010respTime\030\003 \001(\t\022\016\n\006seqNum\030\004 \001(\t\"\212\004" +
+ "\n\014Subscription\022=\n\006header\030\001 \001(\0132-.eventme" +
+ "sh.common.protocol.grpc.RequestHeader\022\025\n" +
+ "\rconsumerGroup\030\002 \001(\t\022X\n\021subscriptionItem" +
+ "s\030\003 \003(\0132=.eventmesh.common.protocol.grpc" +
+ ".Subscription.SubscriptionItem\022\013\n\003url\030\004 " +
+ "\001(\t\032\274\002\n\020SubscriptionItem\022\r\n\005topic\030\001 \001(\t\022" +
+ "\\\n\004mode\030\002 \001(\0162N.eventmesh.common.protoco" +
+ "l.grpc.Subscription.SubscriptionItem.Sub" +
+ "scriptionMode\022\\\n\004type\030\003 \001(\0162N.eventmesh." +
+ "common.protocol.grpc.Subscription.Subscr" +
+ "iptionItem.SubscriptionType\"4\n\020Subscript" +
+ "ionMode\022\016\n\nCLUSTERING\020\000\022\020\n\014BROADCASTING\020" +
+ "\001\"\'\n\020SubscriptionType\022\t\n\005ASYNC\020\000\022\010\n\004SYNC" +
+ "\020\001\"\340\002\n\tHeartbeat\022=\n\006header\030\001 \001(\0132-.event" +
+ "mesh.common.protocol.grpc.RequestHeader\022" +
+ "H\n\nclientType\030\002 \001(\01624.eventmesh.common.p" +
+ "rotocol.grpc.Heartbeat.ClientType\022\025\n\rpro" +
+ "ducerGroup\030\003 \001(\t\022\025\n\rconsumerGroup\030\004 \001(\t\022" +
+ "O\n\016heartbeatItems\030\005 \003(\01327.eventmesh.comm" +
+ "on.protocol.grpc.Heartbeat.HeartbeatItem" +
+ "\032+\n\rHeartbeatItem\022\r\n\005topic\030\001 \001(\t\022\013\n\003url\030" +
+ "\002 \001(\t\"\036\n\nClientType\022\007\n\003PUB\020\000\022\007\n\003SUB\020\0012\316\002" +
+ "\n\020PublisherService\022e\n\007publish\0220.eventmes" +
+ "h.common.protocol.grpc.EventMeshMessage\032" +
+ "(.eventmesh.common.protocol.grpc.Respons" +
+ "e\022j\n\014requestReply\0220.eventmesh.common.pro" +
+ "tocol.grpc.EventMeshMessage\032(.eventmesh." +
+ "common.protocol.grpc.Response\022g\n\tbroadca" +
+ "st\0220.eventmesh.common.protocol.grpc.Even" +
+ "tMeshMessage\032(.eventmesh.common.protocol" +
+ ".grpc.Response2\322\002\n\017ConsumerService\022c\n\tsu" +
+ "bscribe\022,.eventmesh.common.protocol.grpc" +
+ ".Subscription\032(.eventmesh.common.protoco" +
+ "l.grpc.Response\022s\n\017subscribeStream\022,.eve" +
+ "ntmesh.common.protocol.grpc.Subscription" +
+ "\0320.eventmesh.common.protocol.grpc.EventM" +
+ "eshMessage0\001\022e\n\013unsubscribe\022,.eventmesh." +
+ "common.protocol.grpc.Subscription\032(.even" +
+ "tmesh.common.protocol.grpc.Response2t\n\020H" +
+ "eartbeatService\022`\n\theartbeat\022).eventmesh" +
+ ".common.protocol.grpc.Heartbeat\032(.eventm" +
+ "esh.common.protocol.grpc.ResponseBC\n0org" +
+ ".apache.eventmesh.common.protocol.grpc.p" +
+ "rotosB\rEventmeshGrpcP\001b\006proto3"
+ };
+ com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
+ new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
+ public com.google.protobuf.ExtensionRegistry assignDescriptors(
+ com.google.protobuf.Descriptors.FileDescriptor root) {
+ descriptor = root;
+ return null;
+ }
+ };
+ com.google.protobuf.Descriptors.FileDescriptor
+ .internalBuildGeneratedFileFrom(descriptorData,
+ new com.google.protobuf.Descriptors.FileDescriptor[] {
+ }, assigner);
+ internal_static_eventmesh_common_protocol_grpc_RequestHeader_descriptor =
+ getDescriptor().getMessageTypes().get(0);
+ internal_static_eventmesh_common_protocol_grpc_RequestHeader_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+ internal_static_eventmesh_common_protocol_grpc_RequestHeader_descriptor,
+ new String[] { "Env", "Region", "Idc", "Ip", "Pid", "Sys", "Username", "Password", "Language", "ProtocolType", "ProtocolVersion", "ProtocolDesc", });
+ internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor =
+ getDescriptor().getMessageTypes().get(1);
+ internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+ internal_static_eventmesh_common_protocol_grpc_EventMeshMessage_descriptor,
+ new String[] { "Header", "ProducerGroup", "Topic", "Content", "Ttl", "UniqueId", "SeqNum", "Tag", });
+ internal_static_eventmesh_common_protocol_grpc_Response_descriptor =
+ getDescriptor().getMessageTypes().get(2);
+ internal_static_eventmesh_common_protocol_grpc_Response_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+ internal_static_eventmesh_common_protocol_grpc_Response_descriptor,
+ new String[] { "RespCode", "RespMsg", "RespTime", "SeqNum", });
+ internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor =
+ getDescriptor().getMessageTypes().get(3);
+ internal_static_eventmesh_common_protocol_grpc_Subscription_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+ internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor,
+ new String[] { "Header", "ConsumerGroup", "SubscriptionItems", "Url", });
+ internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor =
+ internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor.getNestedTypes().get(0);
+ internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+ internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor,
+ new String[] { "Topic", "Mode", "Type", });
+ internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor =
+ getDescriptor().getMessageTypes().get(4);
+ internal_static_eventmesh_common_protocol_grpc_Heartbeat_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+ internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor,
+ new String[] { "Header", "ClientType", "ProducerGroup", "ConsumerGroup", "HeartbeatItems", });
+ internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_descriptor =
+ internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor.getNestedTypes().get(0);
+ internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+ internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_descriptor,
+ new String[] { "Topic", "Url", });
+ }
+
+ // @@protoc_insertion_point(outer_class_scope)
+}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java
new file mode 100644
index 0000000000..64e95fd3d8
--- /dev/null
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Heartbeat.java
@@ -0,0 +1,2015 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: eventmesh-client.proto
+
+package org.apache.eventmesh.common.protocol.grpc.protos;
+
+/**
+ * Protobuf type {@code eventmesh.common.protocol.grpc.Heartbeat}
+ */
+public final class Heartbeat extends
+ com.google.protobuf.GeneratedMessageV3 implements
+ // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.Heartbeat)
+ HeartbeatOrBuilder {
+private static final long serialVersionUID = 0L;
+ // Use Heartbeat.newBuilder() to construct.
+ private Heartbeat(com.google.protobuf.GeneratedMessageV3.Builder> builder) {
+ super(builder);
+ }
+ private Heartbeat() {
+ clientType_ = 0;
+ producerGroup_ = "";
+ consumerGroup_ = "";
+ heartbeatItems_ = java.util.Collections.emptyList();
+ }
+
+ @Override
+ public final com.google.protobuf.UnknownFieldSet
+ getUnknownFields() {
+ return this.unknownFields;
+ }
+ private Heartbeat(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ this();
+ if (extensionRegistry == null) {
+ throw new NullPointerException();
+ }
+ int mutable_bitField0_ = 0;
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder();
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ default: {
+ if (!parseUnknownFieldProto3(
+ input, unknownFields, extensionRegistry, tag)) {
+ done = true;
+ }
+ break;
+ }
+ case 10: {
+ RequestHeader.Builder subBuilder = null;
+ if (header_ != null) {
+ subBuilder = header_.toBuilder();
+ }
+ header_ = input.readMessage(RequestHeader.parser(), extensionRegistry);
+ if (subBuilder != null) {
+ subBuilder.mergeFrom(header_);
+ header_ = subBuilder.buildPartial();
+ }
+
+ break;
+ }
+ case 16: {
+ int rawValue = input.readEnum();
+
+ clientType_ = rawValue;
+ break;
+ }
+ case 26: {
+ String s = input.readStringRequireUtf8();
+
+ producerGroup_ = s;
+ break;
+ }
+ case 34: {
+ String s = input.readStringRequireUtf8();
+
+ consumerGroup_ = s;
+ break;
+ }
+ case 42: {
+ if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) {
+ heartbeatItems_ = new java.util.ArrayList();
+ mutable_bitField0_ |= 0x00000010;
+ }
+ heartbeatItems_.add(
+ input.readMessage(HeartbeatItem.parser(), extensionRegistry));
+ break;
+ }
+ }
+ }
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(this);
+ } catch (java.io.IOException e) {
+ throw new com.google.protobuf.InvalidProtocolBufferException(
+ e).setUnfinishedMessage(this);
+ } finally {
+ if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) {
+ heartbeatItems_ = java.util.Collections.unmodifiableList(heartbeatItems_);
+ }
+ this.unknownFields = unknownFields.build();
+ makeExtensionsImmutable();
+ }
+ }
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor;
+ }
+
+ protected FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ Heartbeat.class, Builder.class);
+ }
+
+ /**
+ * Protobuf enum {@code eventmesh.common.protocol.grpc.Heartbeat.ClientType}
+ */
+ public enum ClientType
+ implements com.google.protobuf.ProtocolMessageEnum {
+ /**
+ * PUB = 0;
+ */
+ PUB(0),
+ /**
+ * SUB = 1;
+ */
+ SUB(1),
+ UNRECOGNIZED(-1),
+ ;
+
+ /**
+ * PUB = 0;
+ */
+ public static final int PUB_VALUE = 0;
+ /**
+ * SUB = 1;
+ */
+ public static final int SUB_VALUE = 1;
+
+
+ public final int getNumber() {
+ if (this == UNRECOGNIZED) {
+ throw new IllegalArgumentException(
+ "Can't get the number of an unknown enum value.");
+ }
+ return value;
+ }
+
+ /**
+ * @deprecated Use {@link #forNumber(int)} instead.
+ */
+ @Deprecated
+ public static ClientType valueOf(int value) {
+ return forNumber(value);
+ }
+
+ public static ClientType forNumber(int value) {
+ switch (value) {
+ case 0: return PUB;
+ case 1: return SUB;
+ default: return null;
+ }
+ }
+
+ public static com.google.protobuf.Internal.EnumLiteMap
+ internalGetValueMap() {
+ return internalValueMap;
+ }
+ private static final com.google.protobuf.Internal.EnumLiteMap<
+ ClientType> internalValueMap =
+ new com.google.protobuf.Internal.EnumLiteMap() {
+ public ClientType findValueByNumber(int number) {
+ return ClientType.forNumber(number);
+ }
+ };
+
+ public final com.google.protobuf.Descriptors.EnumValueDescriptor
+ getValueDescriptor() {
+ return getDescriptor().getValues().get(ordinal());
+ }
+ public final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptorForType() {
+ return getDescriptor();
+ }
+ public static final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptor() {
+ return Heartbeat.getDescriptor().getEnumTypes().get(0);
+ }
+
+ private static final ClientType[] VALUES = values();
+
+ public static ClientType valueOf(
+ com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
+ if (desc.getType() != getDescriptor()) {
+ throw new IllegalArgumentException(
+ "EnumValueDescriptor is not for this type.");
+ }
+ if (desc.getIndex() == -1) {
+ return UNRECOGNIZED;
+ }
+ return VALUES[desc.getIndex()];
+ }
+
+ private final int value;
+
+ private ClientType(int value) {
+ this.value = value;
+ }
+
+ // @@protoc_insertion_point(enum_scope:eventmesh.common.protocol.grpc.Heartbeat.ClientType)
+ }
+
+ public interface HeartbeatItemOrBuilder extends
+ // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem)
+ com.google.protobuf.MessageOrBuilder {
+
+ /**
+ * string topic = 1;
+ */
+ String getTopic();
+ /**
+ * string topic = 1;
+ */
+ com.google.protobuf.ByteString
+ getTopicBytes();
+
+ /**
+ * string url = 2;
+ */
+ String getUrl();
+ /**
+ * string url = 2;
+ */
+ com.google.protobuf.ByteString
+ getUrlBytes();
+ }
+ /**
+ * Protobuf type {@code eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem}
+ */
+ public static final class HeartbeatItem extends
+ com.google.protobuf.GeneratedMessageV3 implements
+ // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem)
+ HeartbeatItemOrBuilder {
+ private static final long serialVersionUID = 0L;
+ // Use HeartbeatItem.newBuilder() to construct.
+ private HeartbeatItem(com.google.protobuf.GeneratedMessageV3.Builder> builder) {
+ super(builder);
+ }
+ private HeartbeatItem() {
+ topic_ = "";
+ url_ = "";
+ }
+
+ @Override
+ public final com.google.protobuf.UnknownFieldSet
+ getUnknownFields() {
+ return this.unknownFields;
+ }
+ private HeartbeatItem(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ this();
+ if (extensionRegistry == null) {
+ throw new NullPointerException();
+ }
+ int mutable_bitField0_ = 0;
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder();
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ default: {
+ if (!parseUnknownFieldProto3(
+ input, unknownFields, extensionRegistry, tag)) {
+ done = true;
+ }
+ break;
+ }
+ case 10: {
+ String s = input.readStringRequireUtf8();
+
+ topic_ = s;
+ break;
+ }
+ case 18: {
+ String s = input.readStringRequireUtf8();
+
+ url_ = s;
+ break;
+ }
+ }
+ }
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(this);
+ } catch (java.io.IOException e) {
+ throw new com.google.protobuf.InvalidProtocolBufferException(
+ e).setUnfinishedMessage(this);
+ } finally {
+ this.unknownFields = unknownFields.build();
+ makeExtensionsImmutable();
+ }
+ }
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_descriptor;
+ }
+
+ protected FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ HeartbeatItem.class, Builder.class);
+ }
+
+ public static final int TOPIC_FIELD_NUMBER = 1;
+ private volatile Object topic_;
+ /**
+ * string topic = 1;
+ */
+ public String getTopic() {
+ Object ref = topic_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ topic_ = s;
+ return s;
+ }
+ }
+ /**
+ * string topic = 1;
+ */
+ public com.google.protobuf.ByteString
+ getTopicBytes() {
+ Object ref = topic_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ topic_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int URL_FIELD_NUMBER = 2;
+ private volatile Object url_;
+ /**
+ * string url = 2;
+ */
+ public String getUrl() {
+ Object ref = url_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ url_ = s;
+ return s;
+ }
+ }
+ /**
+ * string url = 2;
+ */
+ public com.google.protobuf.ByteString
+ getUrlBytes() {
+ Object ref = url_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ url_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized == 1) return true;
+ if (isInitialized == 0) return false;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ if (!getTopicBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 1, topic_);
+ }
+ if (!getUrlBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 2, url_);
+ }
+ unknownFields.writeTo(output);
+ }
+
+ public int getSerializedSize() {
+ int size = memoizedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (!getTopicBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, topic_);
+ }
+ if (!getUrlBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, url_);
+ }
+ size += unknownFields.getSerializedSize();
+ memoizedSize = size;
+ return size;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof HeartbeatItem)) {
+ return super.equals(obj);
+ }
+ HeartbeatItem other = (HeartbeatItem) obj;
+
+ boolean result = true;
+ result = result && getTopic()
+ .equals(other.getTopic());
+ result = result && getUrl()
+ .equals(other.getUrl());
+ result = result && unknownFields.equals(other.unknownFields);
+ return result;
+ }
+
+ @Override
+ public int hashCode() {
+ if (memoizedHashCode != 0) {
+ return memoizedHashCode;
+ }
+ int hash = 41;
+ hash = (19 * hash) + getDescriptor().hashCode();
+ hash = (37 * hash) + TOPIC_FIELD_NUMBER;
+ hash = (53 * hash) + getTopic().hashCode();
+ hash = (37 * hash) + URL_FIELD_NUMBER;
+ hash = (53 * hash) + getUrl().hashCode();
+ hash = (29 * hash) + unknownFields.hashCode();
+ memoizedHashCode = hash;
+ return hash;
+ }
+
+ public static HeartbeatItem parseFrom(
+ java.nio.ByteBuffer data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static HeartbeatItem parseFrom(
+ java.nio.ByteBuffer data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static HeartbeatItem parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static HeartbeatItem parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static HeartbeatItem parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static HeartbeatItem parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static HeartbeatItem parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static HeartbeatItem parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static HeartbeatItem parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input);
+ }
+ public static HeartbeatItem parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static HeartbeatItem parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static HeartbeatItem parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder() {
+ return DEFAULT_INSTANCE.toBuilder();
+ }
+ public static Builder newBuilder(HeartbeatItem prototype) {
+ return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() {
+ return this == DEFAULT_INSTANCE
+ ? new Builder() : new Builder().mergeFrom(this);
+ }
+
+ @Override
+ protected Builder newBuilderForType(
+ BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ * Protobuf type {@code eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem}
+ */
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessageV3.Builder implements
+ // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem)
+ HeartbeatItemOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_descriptor;
+ }
+
+ protected FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ HeartbeatItem.class, Builder.class);
+ }
+
+ // Construct using org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat.HeartbeatItem.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(
+ BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessageV3
+ .alwaysUseFieldBuilders) {
+ }
+ }
+ public Builder clear() {
+ super.clear();
+ topic_ = "";
+
+ url_ = "";
+
+ return this;
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_HeartbeatItem_descriptor;
+ }
+
+ public HeartbeatItem getDefaultInstanceForType() {
+ return HeartbeatItem.getDefaultInstance();
+ }
+
+ public HeartbeatItem build() {
+ HeartbeatItem result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ public HeartbeatItem buildPartial() {
+ HeartbeatItem result = new HeartbeatItem(this);
+ result.topic_ = topic_;
+ result.url_ = url_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder clone() {
+ return (Builder) super.clone();
+ }
+ public Builder setField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ Object value) {
+ return (Builder) super.setField(field, value);
+ }
+ public Builder clearField(
+ com.google.protobuf.Descriptors.FieldDescriptor field) {
+ return (Builder) super.clearField(field);
+ }
+ public Builder clearOneof(
+ com.google.protobuf.Descriptors.OneofDescriptor oneof) {
+ return (Builder) super.clearOneof(oneof);
+ }
+ public Builder setRepeatedField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ int index, Object value) {
+ return (Builder) super.setRepeatedField(field, index, value);
+ }
+ public Builder addRepeatedField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ Object value) {
+ return (Builder) super.addRepeatedField(field, value);
+ }
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof HeartbeatItem) {
+ return mergeFrom((HeartbeatItem)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(HeartbeatItem other) {
+ if (other == HeartbeatItem.getDefaultInstance()) return this;
+ if (!other.getTopic().isEmpty()) {
+ topic_ = other.topic_;
+ onChanged();
+ }
+ if (!other.getUrl().isEmpty()) {
+ url_ = other.url_;
+ onChanged();
+ }
+ this.mergeUnknownFields(other.unknownFields);
+ onChanged();
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ HeartbeatItem parsedMessage = null;
+ try {
+ parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ parsedMessage = (HeartbeatItem) e.getUnfinishedMessage();
+ throw e.unwrapIOException();
+ } finally {
+ if (parsedMessage != null) {
+ mergeFrom(parsedMessage);
+ }
+ }
+ return this;
+ }
+
+ private Object topic_ = "";
+ /**
+ * string topic = 1;
+ */
+ public String getTopic() {
+ Object ref = topic_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ topic_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string topic = 1;
+ */
+ public com.google.protobuf.ByteString
+ getTopicBytes() {
+ Object ref = topic_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ topic_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string topic = 1;
+ */
+ public Builder setTopic(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ topic_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string topic = 1;
+ */
+ public Builder clearTopic() {
+
+ topic_ = getDefaultInstance().getTopic();
+ onChanged();
+ return this;
+ }
+ /**
+ * string topic = 1;
+ */
+ public Builder setTopicBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ topic_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object url_ = "";
+ /**
+ * string url = 2;
+ */
+ public String getUrl() {
+ Object ref = url_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ url_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string url = 2;
+ */
+ public com.google.protobuf.ByteString
+ getUrlBytes() {
+ Object ref = url_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ url_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string url = 2;
+ */
+ public Builder setUrl(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ url_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string url = 2;
+ */
+ public Builder clearUrl() {
+
+ url_ = getDefaultInstance().getUrl();
+ onChanged();
+ return this;
+ }
+ /**
+ * string url = 2;
+ */
+ public Builder setUrlBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ url_ = value;
+ onChanged();
+ return this;
+ }
+ public final Builder setUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.setUnknownFieldsProto3(unknownFields);
+ }
+
+ public final Builder mergeUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.mergeUnknownFields(unknownFields);
+ }
+
+
+ // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem)
+ }
+
+ // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem)
+ private static final HeartbeatItem DEFAULT_INSTANCE;
+ static {
+ DEFAULT_INSTANCE = new HeartbeatItem();
+ }
+
+ public static HeartbeatItem getDefaultInstance() {
+ return DEFAULT_INSTANCE;
+ }
+
+ private static final com.google.protobuf.Parser
+ PARSER = new com.google.protobuf.AbstractParser() {
+ public HeartbeatItem parsePartialFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return new HeartbeatItem(input, extensionRegistry);
+ }
+ };
+
+ public static com.google.protobuf.Parser parser() {
+ return PARSER;
+ }
+
+ @Override
+ public com.google.protobuf.Parser getParserForType() {
+ return PARSER;
+ }
+
+ public HeartbeatItem getDefaultInstanceForType() {
+ return DEFAULT_INSTANCE;
+ }
+
+ }
+
+ private int bitField0_;
+ public static final int HEADER_FIELD_NUMBER = 1;
+ private RequestHeader header_;
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public boolean hasHeader() {
+ return header_ != null;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public RequestHeader getHeader() {
+ return header_ == null ? RequestHeader.getDefaultInstance() : header_;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public RequestHeaderOrBuilder getHeaderOrBuilder() {
+ return getHeader();
+ }
+
+ public static final int CLIENTTYPE_FIELD_NUMBER = 2;
+ private int clientType_;
+ /**
+ * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2;
+ */
+ public int getClientTypeValue() {
+ return clientType_;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2;
+ */
+ public ClientType getClientType() {
+ ClientType result = ClientType.valueOf(clientType_);
+ return result == null ? ClientType.UNRECOGNIZED : result;
+ }
+
+ public static final int PRODUCERGROUP_FIELD_NUMBER = 3;
+ private volatile Object producerGroup_;
+ /**
+ * string producerGroup = 3;
+ */
+ public String getProducerGroup() {
+ Object ref = producerGroup_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ producerGroup_ = s;
+ return s;
+ }
+ }
+ /**
+ * string producerGroup = 3;
+ */
+ public com.google.protobuf.ByteString
+ getProducerGroupBytes() {
+ Object ref = producerGroup_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ producerGroup_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int CONSUMERGROUP_FIELD_NUMBER = 4;
+ private volatile Object consumerGroup_;
+ /**
+ * string consumerGroup = 4;
+ */
+ public String getConsumerGroup() {
+ Object ref = consumerGroup_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ consumerGroup_ = s;
+ return s;
+ }
+ }
+ /**
+ * string consumerGroup = 4;
+ */
+ public com.google.protobuf.ByteString
+ getConsumerGroupBytes() {
+ Object ref = consumerGroup_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ consumerGroup_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int HEARTBEATITEMS_FIELD_NUMBER = 5;
+ private java.util.List heartbeatItems_;
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public java.util.List getHeartbeatItemsList() {
+ return heartbeatItems_;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public java.util.List extends HeartbeatItemOrBuilder>
+ getHeartbeatItemsOrBuilderList() {
+ return heartbeatItems_;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public int getHeartbeatItemsCount() {
+ return heartbeatItems_.size();
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public HeartbeatItem getHeartbeatItems(int index) {
+ return heartbeatItems_.get(index);
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public HeartbeatItemOrBuilder getHeartbeatItemsOrBuilder(
+ int index) {
+ return heartbeatItems_.get(index);
+ }
+
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized == 1) return true;
+ if (isInitialized == 0) return false;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ if (header_ != null) {
+ output.writeMessage(1, getHeader());
+ }
+ if (clientType_ != ClientType.PUB.getNumber()) {
+ output.writeEnum(2, clientType_);
+ }
+ if (!getProducerGroupBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 3, producerGroup_);
+ }
+ if (!getConsumerGroupBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 4, consumerGroup_);
+ }
+ for (int i = 0; i < heartbeatItems_.size(); i++) {
+ output.writeMessage(5, heartbeatItems_.get(i));
+ }
+ unknownFields.writeTo(output);
+ }
+
+ public int getSerializedSize() {
+ int size = memoizedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (header_ != null) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeMessageSize(1, getHeader());
+ }
+ if (clientType_ != ClientType.PUB.getNumber()) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeEnumSize(2, clientType_);
+ }
+ if (!getProducerGroupBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, producerGroup_);
+ }
+ if (!getConsumerGroupBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, consumerGroup_);
+ }
+ for (int i = 0; i < heartbeatItems_.size(); i++) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeMessageSize(5, heartbeatItems_.get(i));
+ }
+ size += unknownFields.getSerializedSize();
+ memoizedSize = size;
+ return size;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof Heartbeat)) {
+ return super.equals(obj);
+ }
+ Heartbeat other = (Heartbeat) obj;
+
+ boolean result = true;
+ result = result && (hasHeader() == other.hasHeader());
+ if (hasHeader()) {
+ result = result && getHeader()
+ .equals(other.getHeader());
+ }
+ result = result && clientType_ == other.clientType_;
+ result = result && getProducerGroup()
+ .equals(other.getProducerGroup());
+ result = result && getConsumerGroup()
+ .equals(other.getConsumerGroup());
+ result = result && getHeartbeatItemsList()
+ .equals(other.getHeartbeatItemsList());
+ result = result && unknownFields.equals(other.unknownFields);
+ return result;
+ }
+
+ @Override
+ public int hashCode() {
+ if (memoizedHashCode != 0) {
+ return memoizedHashCode;
+ }
+ int hash = 41;
+ hash = (19 * hash) + getDescriptor().hashCode();
+ if (hasHeader()) {
+ hash = (37 * hash) + HEADER_FIELD_NUMBER;
+ hash = (53 * hash) + getHeader().hashCode();
+ }
+ hash = (37 * hash) + CLIENTTYPE_FIELD_NUMBER;
+ hash = (53 * hash) + clientType_;
+ hash = (37 * hash) + PRODUCERGROUP_FIELD_NUMBER;
+ hash = (53 * hash) + getProducerGroup().hashCode();
+ hash = (37 * hash) + CONSUMERGROUP_FIELD_NUMBER;
+ hash = (53 * hash) + getConsumerGroup().hashCode();
+ if (getHeartbeatItemsCount() > 0) {
+ hash = (37 * hash) + HEARTBEATITEMS_FIELD_NUMBER;
+ hash = (53 * hash) + getHeartbeatItemsList().hashCode();
+ }
+ hash = (29 * hash) + unknownFields.hashCode();
+ memoizedHashCode = hash;
+ return hash;
+ }
+
+ public static Heartbeat parseFrom(
+ java.nio.ByteBuffer data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static Heartbeat parseFrom(
+ java.nio.ByteBuffer data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static Heartbeat parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static Heartbeat parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static Heartbeat parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static Heartbeat parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static Heartbeat parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static Heartbeat parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static Heartbeat parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input);
+ }
+ public static Heartbeat parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static Heartbeat parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static Heartbeat parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder() {
+ return DEFAULT_INSTANCE.toBuilder();
+ }
+ public static Builder newBuilder(Heartbeat prototype) {
+ return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() {
+ return this == DEFAULT_INSTANCE
+ ? new Builder() : new Builder().mergeFrom(this);
+ }
+
+ @Override
+ protected Builder newBuilderForType(
+ BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ * Protobuf type {@code eventmesh.common.protocol.grpc.Heartbeat}
+ */
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessageV3.Builder implements
+ // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.Heartbeat)
+ HeartbeatOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor;
+ }
+
+ protected FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ Heartbeat.class, Builder.class);
+ }
+
+ // Construct using org.apache.eventmesh.common.protocol.grpc.protos.Heartbeat.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(
+ BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessageV3
+ .alwaysUseFieldBuilders) {
+ getHeartbeatItemsFieldBuilder();
+ }
+ }
+ public Builder clear() {
+ super.clear();
+ if (headerBuilder_ == null) {
+ header_ = null;
+ } else {
+ header_ = null;
+ headerBuilder_ = null;
+ }
+ clientType_ = 0;
+
+ producerGroup_ = "";
+
+ consumerGroup_ = "";
+
+ if (heartbeatItemsBuilder_ == null) {
+ heartbeatItems_ = java.util.Collections.emptyList();
+ bitField0_ = (bitField0_ & ~0x00000010);
+ } else {
+ heartbeatItemsBuilder_.clear();
+ }
+ return this;
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Heartbeat_descriptor;
+ }
+
+ public Heartbeat getDefaultInstanceForType() {
+ return Heartbeat.getDefaultInstance();
+ }
+
+ public Heartbeat build() {
+ Heartbeat result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ public Heartbeat buildPartial() {
+ Heartbeat result = new Heartbeat(this);
+ int from_bitField0_ = bitField0_;
+ int to_bitField0_ = 0;
+ if (headerBuilder_ == null) {
+ result.header_ = header_;
+ } else {
+ result.header_ = headerBuilder_.build();
+ }
+ result.clientType_ = clientType_;
+ result.producerGroup_ = producerGroup_;
+ result.consumerGroup_ = consumerGroup_;
+ if (heartbeatItemsBuilder_ == null) {
+ if (((bitField0_ & 0x00000010) == 0x00000010)) {
+ heartbeatItems_ = java.util.Collections.unmodifiableList(heartbeatItems_);
+ bitField0_ = (bitField0_ & ~0x00000010);
+ }
+ result.heartbeatItems_ = heartbeatItems_;
+ } else {
+ result.heartbeatItems_ = heartbeatItemsBuilder_.build();
+ }
+ result.bitField0_ = to_bitField0_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder clone() {
+ return (Builder) super.clone();
+ }
+ public Builder setField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ Object value) {
+ return (Builder) super.setField(field, value);
+ }
+ public Builder clearField(
+ com.google.protobuf.Descriptors.FieldDescriptor field) {
+ return (Builder) super.clearField(field);
+ }
+ public Builder clearOneof(
+ com.google.protobuf.Descriptors.OneofDescriptor oneof) {
+ return (Builder) super.clearOneof(oneof);
+ }
+ public Builder setRepeatedField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ int index, Object value) {
+ return (Builder) super.setRepeatedField(field, index, value);
+ }
+ public Builder addRepeatedField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ Object value) {
+ return (Builder) super.addRepeatedField(field, value);
+ }
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof Heartbeat) {
+ return mergeFrom((Heartbeat)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(Heartbeat other) {
+ if (other == Heartbeat.getDefaultInstance()) return this;
+ if (other.hasHeader()) {
+ mergeHeader(other.getHeader());
+ }
+ if (other.clientType_ != 0) {
+ setClientTypeValue(other.getClientTypeValue());
+ }
+ if (!other.getProducerGroup().isEmpty()) {
+ producerGroup_ = other.producerGroup_;
+ onChanged();
+ }
+ if (!other.getConsumerGroup().isEmpty()) {
+ consumerGroup_ = other.consumerGroup_;
+ onChanged();
+ }
+ if (heartbeatItemsBuilder_ == null) {
+ if (!other.heartbeatItems_.isEmpty()) {
+ if (heartbeatItems_.isEmpty()) {
+ heartbeatItems_ = other.heartbeatItems_;
+ bitField0_ = (bitField0_ & ~0x00000010);
+ } else {
+ ensureHeartbeatItemsIsMutable();
+ heartbeatItems_.addAll(other.heartbeatItems_);
+ }
+ onChanged();
+ }
+ } else {
+ if (!other.heartbeatItems_.isEmpty()) {
+ if (heartbeatItemsBuilder_.isEmpty()) {
+ heartbeatItemsBuilder_.dispose();
+ heartbeatItemsBuilder_ = null;
+ heartbeatItems_ = other.heartbeatItems_;
+ bitField0_ = (bitField0_ & ~0x00000010);
+ heartbeatItemsBuilder_ =
+ com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+ getHeartbeatItemsFieldBuilder() : null;
+ } else {
+ heartbeatItemsBuilder_.addAllMessages(other.heartbeatItems_);
+ }
+ }
+ }
+ this.mergeUnknownFields(other.unknownFields);
+ onChanged();
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ Heartbeat parsedMessage = null;
+ try {
+ parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ parsedMessage = (Heartbeat) e.getUnfinishedMessage();
+ throw e.unwrapIOException();
+ } finally {
+ if (parsedMessage != null) {
+ mergeFrom(parsedMessage);
+ }
+ }
+ return this;
+ }
+ private int bitField0_;
+
+ private RequestHeader header_ = null;
+ private com.google.protobuf.SingleFieldBuilderV3<
+ RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> headerBuilder_;
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public boolean hasHeader() {
+ return headerBuilder_ != null || header_ != null;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public RequestHeader getHeader() {
+ if (headerBuilder_ == null) {
+ return header_ == null ? RequestHeader.getDefaultInstance() : header_;
+ } else {
+ return headerBuilder_.getMessage();
+ }
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public Builder setHeader(RequestHeader value) {
+ if (headerBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ header_ = value;
+ onChanged();
+ } else {
+ headerBuilder_.setMessage(value);
+ }
+
+ return this;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public Builder setHeader(
+ RequestHeader.Builder builderForValue) {
+ if (headerBuilder_ == null) {
+ header_ = builderForValue.build();
+ onChanged();
+ } else {
+ headerBuilder_.setMessage(builderForValue.build());
+ }
+
+ return this;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public Builder mergeHeader(RequestHeader value) {
+ if (headerBuilder_ == null) {
+ if (header_ != null) {
+ header_ =
+ RequestHeader.newBuilder(header_).mergeFrom(value).buildPartial();
+ } else {
+ header_ = value;
+ }
+ onChanged();
+ } else {
+ headerBuilder_.mergeFrom(value);
+ }
+
+ return this;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public Builder clearHeader() {
+ if (headerBuilder_ == null) {
+ header_ = null;
+ onChanged();
+ } else {
+ header_ = null;
+ headerBuilder_ = null;
+ }
+
+ return this;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public RequestHeader.Builder getHeaderBuilder() {
+
+ onChanged();
+ return getHeaderFieldBuilder().getBuilder();
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public RequestHeaderOrBuilder getHeaderOrBuilder() {
+ if (headerBuilder_ != null) {
+ return headerBuilder_.getMessageOrBuilder();
+ } else {
+ return header_ == null ?
+ RequestHeader.getDefaultInstance() : header_;
+ }
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ private com.google.protobuf.SingleFieldBuilderV3<
+ RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>
+ getHeaderFieldBuilder() {
+ if (headerBuilder_ == null) {
+ headerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
+ RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>(
+ getHeader(),
+ getParentForChildren(),
+ isClean());
+ header_ = null;
+ }
+ return headerBuilder_;
+ }
+
+ private int clientType_ = 0;
+ /**
+ * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2;
+ */
+ public int getClientTypeValue() {
+ return clientType_;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2;
+ */
+ public Builder setClientTypeValue(int value) {
+ clientType_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2;
+ */
+ public ClientType getClientType() {
+ ClientType result = ClientType.valueOf(clientType_);
+ return result == null ? ClientType.UNRECOGNIZED : result;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2;
+ */
+ public Builder setClientType(ClientType value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ clientType_ = value.getNumber();
+ onChanged();
+ return this;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2;
+ */
+ public Builder clearClientType() {
+
+ clientType_ = 0;
+ onChanged();
+ return this;
+ }
+
+ private Object producerGroup_ = "";
+ /**
+ * string producerGroup = 3;
+ */
+ public String getProducerGroup() {
+ Object ref = producerGroup_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ producerGroup_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string producerGroup = 3;
+ */
+ public com.google.protobuf.ByteString
+ getProducerGroupBytes() {
+ Object ref = producerGroup_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ producerGroup_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string producerGroup = 3;
+ */
+ public Builder setProducerGroup(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ producerGroup_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string producerGroup = 3;
+ */
+ public Builder clearProducerGroup() {
+
+ producerGroup_ = getDefaultInstance().getProducerGroup();
+ onChanged();
+ return this;
+ }
+ /**
+ * string producerGroup = 3;
+ */
+ public Builder setProducerGroupBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ producerGroup_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object consumerGroup_ = "";
+ /**
+ * string consumerGroup = 4;
+ */
+ public String getConsumerGroup() {
+ Object ref = consumerGroup_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ consumerGroup_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string consumerGroup = 4;
+ */
+ public com.google.protobuf.ByteString
+ getConsumerGroupBytes() {
+ Object ref = consumerGroup_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ consumerGroup_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string consumerGroup = 4;
+ */
+ public Builder setConsumerGroup(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ consumerGroup_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string consumerGroup = 4;
+ */
+ public Builder clearConsumerGroup() {
+
+ consumerGroup_ = getDefaultInstance().getConsumerGroup();
+ onChanged();
+ return this;
+ }
+ /**
+ * string consumerGroup = 4;
+ */
+ public Builder setConsumerGroupBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ consumerGroup_ = value;
+ onChanged();
+ return this;
+ }
+
+ private java.util.List heartbeatItems_ =
+ java.util.Collections.emptyList();
+ private void ensureHeartbeatItemsIsMutable() {
+ if (!((bitField0_ & 0x00000010) == 0x00000010)) {
+ heartbeatItems_ = new java.util.ArrayList(heartbeatItems_);
+ bitField0_ |= 0x00000010;
+ }
+ }
+
+ private com.google.protobuf.RepeatedFieldBuilderV3<
+ HeartbeatItem, HeartbeatItem.Builder, HeartbeatItemOrBuilder> heartbeatItemsBuilder_;
+
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public java.util.List getHeartbeatItemsList() {
+ if (heartbeatItemsBuilder_ == null) {
+ return java.util.Collections.unmodifiableList(heartbeatItems_);
+ } else {
+ return heartbeatItemsBuilder_.getMessageList();
+ }
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public int getHeartbeatItemsCount() {
+ if (heartbeatItemsBuilder_ == null) {
+ return heartbeatItems_.size();
+ } else {
+ return heartbeatItemsBuilder_.getCount();
+ }
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public HeartbeatItem getHeartbeatItems(int index) {
+ if (heartbeatItemsBuilder_ == null) {
+ return heartbeatItems_.get(index);
+ } else {
+ return heartbeatItemsBuilder_.getMessage(index);
+ }
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public Builder setHeartbeatItems(
+ int index, HeartbeatItem value) {
+ if (heartbeatItemsBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureHeartbeatItemsIsMutable();
+ heartbeatItems_.set(index, value);
+ onChanged();
+ } else {
+ heartbeatItemsBuilder_.setMessage(index, value);
+ }
+ return this;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public Builder setHeartbeatItems(
+ int index, HeartbeatItem.Builder builderForValue) {
+ if (heartbeatItemsBuilder_ == null) {
+ ensureHeartbeatItemsIsMutable();
+ heartbeatItems_.set(index, builderForValue.build());
+ onChanged();
+ } else {
+ heartbeatItemsBuilder_.setMessage(index, builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public Builder addHeartbeatItems(HeartbeatItem value) {
+ if (heartbeatItemsBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureHeartbeatItemsIsMutable();
+ heartbeatItems_.add(value);
+ onChanged();
+ } else {
+ heartbeatItemsBuilder_.addMessage(value);
+ }
+ return this;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public Builder addHeartbeatItems(
+ int index, HeartbeatItem value) {
+ if (heartbeatItemsBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureHeartbeatItemsIsMutable();
+ heartbeatItems_.add(index, value);
+ onChanged();
+ } else {
+ heartbeatItemsBuilder_.addMessage(index, value);
+ }
+ return this;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public Builder addHeartbeatItems(
+ HeartbeatItem.Builder builderForValue) {
+ if (heartbeatItemsBuilder_ == null) {
+ ensureHeartbeatItemsIsMutable();
+ heartbeatItems_.add(builderForValue.build());
+ onChanged();
+ } else {
+ heartbeatItemsBuilder_.addMessage(builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public Builder addHeartbeatItems(
+ int index, HeartbeatItem.Builder builderForValue) {
+ if (heartbeatItemsBuilder_ == null) {
+ ensureHeartbeatItemsIsMutable();
+ heartbeatItems_.add(index, builderForValue.build());
+ onChanged();
+ } else {
+ heartbeatItemsBuilder_.addMessage(index, builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public Builder addAllHeartbeatItems(
+ Iterable extends HeartbeatItem> values) {
+ if (heartbeatItemsBuilder_ == null) {
+ ensureHeartbeatItemsIsMutable();
+ com.google.protobuf.AbstractMessageLite.Builder.addAll(
+ values, heartbeatItems_);
+ onChanged();
+ } else {
+ heartbeatItemsBuilder_.addAllMessages(values);
+ }
+ return this;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public Builder clearHeartbeatItems() {
+ if (heartbeatItemsBuilder_ == null) {
+ heartbeatItems_ = java.util.Collections.emptyList();
+ bitField0_ = (bitField0_ & ~0x00000010);
+ onChanged();
+ } else {
+ heartbeatItemsBuilder_.clear();
+ }
+ return this;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public Builder removeHeartbeatItems(int index) {
+ if (heartbeatItemsBuilder_ == null) {
+ ensureHeartbeatItemsIsMutable();
+ heartbeatItems_.remove(index);
+ onChanged();
+ } else {
+ heartbeatItemsBuilder_.remove(index);
+ }
+ return this;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public HeartbeatItem.Builder getHeartbeatItemsBuilder(
+ int index) {
+ return getHeartbeatItemsFieldBuilder().getBuilder(index);
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public HeartbeatItemOrBuilder getHeartbeatItemsOrBuilder(
+ int index) {
+ if (heartbeatItemsBuilder_ == null) {
+ return heartbeatItems_.get(index); } else {
+ return heartbeatItemsBuilder_.getMessageOrBuilder(index);
+ }
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public java.util.List extends HeartbeatItemOrBuilder>
+ getHeartbeatItemsOrBuilderList() {
+ if (heartbeatItemsBuilder_ != null) {
+ return heartbeatItemsBuilder_.getMessageOrBuilderList();
+ } else {
+ return java.util.Collections.unmodifiableList(heartbeatItems_);
+ }
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public HeartbeatItem.Builder addHeartbeatItemsBuilder() {
+ return getHeartbeatItemsFieldBuilder().addBuilder(
+ HeartbeatItem.getDefaultInstance());
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public HeartbeatItem.Builder addHeartbeatItemsBuilder(
+ int index) {
+ return getHeartbeatItemsFieldBuilder().addBuilder(
+ index, HeartbeatItem.getDefaultInstance());
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ public java.util.List
+ getHeartbeatItemsBuilderList() {
+ return getHeartbeatItemsFieldBuilder().getBuilderList();
+ }
+ private com.google.protobuf.RepeatedFieldBuilderV3<
+ HeartbeatItem, HeartbeatItem.Builder, HeartbeatItemOrBuilder>
+ getHeartbeatItemsFieldBuilder() {
+ if (heartbeatItemsBuilder_ == null) {
+ heartbeatItemsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
+ HeartbeatItem, HeartbeatItem.Builder, HeartbeatItemOrBuilder>(
+ heartbeatItems_,
+ ((bitField0_ & 0x00000010) == 0x00000010),
+ getParentForChildren(),
+ isClean());
+ heartbeatItems_ = null;
+ }
+ return heartbeatItemsBuilder_;
+ }
+ public final Builder setUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.setUnknownFieldsProto3(unknownFields);
+ }
+
+ public final Builder mergeUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.mergeUnknownFields(unknownFields);
+ }
+
+
+ // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.Heartbeat)
+ }
+
+ // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.Heartbeat)
+ private static final Heartbeat DEFAULT_INSTANCE;
+ static {
+ DEFAULT_INSTANCE = new Heartbeat();
+ }
+
+ public static Heartbeat getDefaultInstance() {
+ return DEFAULT_INSTANCE;
+ }
+
+ private static final com.google.protobuf.Parser
+ PARSER = new com.google.protobuf.AbstractParser() {
+ public Heartbeat parsePartialFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return new Heartbeat(input, extensionRegistry);
+ }
+ };
+
+ public static com.google.protobuf.Parser parser() {
+ return PARSER;
+ }
+
+ @Override
+ public com.google.protobuf.Parser getParserForType() {
+ return PARSER;
+ }
+
+ public Heartbeat getDefaultInstanceForType() {
+ return DEFAULT_INSTANCE;
+ }
+
+}
+
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java
new file mode 100644
index 0000000000..7c900099a2
--- /dev/null
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatOrBuilder.java
@@ -0,0 +1,75 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: eventmesh-client.proto
+
+package org.apache.eventmesh.common.protocol.grpc.protos;
+
+public interface HeartbeatOrBuilder extends
+ // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.Heartbeat)
+ com.google.protobuf.MessageOrBuilder {
+
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ boolean hasHeader();
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ RequestHeader getHeader();
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ RequestHeaderOrBuilder getHeaderOrBuilder();
+
+ /**
+ * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2;
+ */
+ int getClientTypeValue();
+ /**
+ * .eventmesh.common.protocol.grpc.Heartbeat.ClientType clientType = 2;
+ */
+ Heartbeat.ClientType getClientType();
+
+ /**
+ * string producerGroup = 3;
+ */
+ String getProducerGroup();
+ /**
+ * string producerGroup = 3;
+ */
+ com.google.protobuf.ByteString
+ getProducerGroupBytes();
+
+ /**
+ * string consumerGroup = 4;
+ */
+ String getConsumerGroup();
+ /**
+ * string consumerGroup = 4;
+ */
+ com.google.protobuf.ByteString
+ getConsumerGroupBytes();
+
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ java.util.List
+ getHeartbeatItemsList();
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ Heartbeat.HeartbeatItem getHeartbeatItems(int index);
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ int getHeartbeatItemsCount();
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ java.util.List extends Heartbeat.HeartbeatItemOrBuilder>
+ getHeartbeatItemsOrBuilderList();
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Heartbeat.HeartbeatItem heartbeatItems = 5;
+ */
+ Heartbeat.HeartbeatItemOrBuilder getHeartbeatItemsOrBuilder(
+ int index);
+}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java
new file mode 100644
index 0000000000..5224e01d0a
--- /dev/null
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/HeartbeatServiceGrpc.java
@@ -0,0 +1,280 @@
+package org.apache.eventmesh.common.protocol.grpc.protos;
+
+import static io.grpc.MethodDescriptor.generateFullMethodName;
+import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncUnaryCall;
+import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
+import static io.grpc.stub.ClientCalls.blockingUnaryCall;
+import static io.grpc.stub.ClientCalls.futureUnaryCall;
+import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncUnaryCall;
+import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
+
+/**
+ */
+@javax.annotation.Generated(
+ value = "by gRPC proto compiler (version 1.15.0)",
+ comments = "Source: eventmesh-client.proto")
+public final class HeartbeatServiceGrpc {
+
+ private HeartbeatServiceGrpc() {}
+
+ public static final String SERVICE_NAME = "eventmesh.common.protocol.grpc.HeartbeatService";
+
+ // Static method descriptors that strictly reflect the proto.
+ private static volatile io.grpc.MethodDescriptor getHeartbeatMethod;
+
+ @io.grpc.stub.annotations.RpcMethod(
+ fullMethodName = SERVICE_NAME + '/' + "heartbeat",
+ requestType = Heartbeat.class,
+ responseType = Response.class,
+ methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
+ public static io.grpc.MethodDescriptor getHeartbeatMethod() {
+ io.grpc.MethodDescriptor getHeartbeatMethod;
+ if ((getHeartbeatMethod = HeartbeatServiceGrpc.getHeartbeatMethod) == null) {
+ synchronized (HeartbeatServiceGrpc.class) {
+ if ((getHeartbeatMethod = HeartbeatServiceGrpc.getHeartbeatMethod) == null) {
+ HeartbeatServiceGrpc.getHeartbeatMethod = getHeartbeatMethod =
+ io.grpc.MethodDescriptor.newBuilder()
+ .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName(generateFullMethodName(
+ "eventmesh.common.protocol.grpc.HeartbeatService", "heartbeat"))
+ .setSampledToLocalTracing(true)
+ .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+ Heartbeat.getDefaultInstance()))
+ .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+ Response.getDefaultInstance()))
+ .setSchemaDescriptor(new HeartbeatServiceMethodDescriptorSupplier("heartbeat"))
+ .build();
+ }
+ }
+ }
+ return getHeartbeatMethod;
+ }
+
+ /**
+ * Creates a new async stub that supports all call types for the service
+ */
+ public static HeartbeatServiceStub newStub(io.grpc.Channel channel) {
+ return new HeartbeatServiceStub(channel);
+ }
+
+ /**
+ * Creates a new blocking-style stub that supports unary and streaming output calls on the service
+ */
+ public static HeartbeatServiceBlockingStub newBlockingStub(
+ io.grpc.Channel channel) {
+ return new HeartbeatServiceBlockingStub(channel);
+ }
+
+ /**
+ * Creates a new ListenableFuture-style stub that supports unary calls on the service
+ */
+ public static HeartbeatServiceFutureStub newFutureStub(
+ io.grpc.Channel channel) {
+ return new HeartbeatServiceFutureStub(channel);
+ }
+
+ /**
+ */
+ public static abstract class HeartbeatServiceImplBase implements io.grpc.BindableService {
+
+ /**
+ */
+ public void heartbeat(Heartbeat request,
+ io.grpc.stub.StreamObserver responseObserver) {
+ asyncUnimplementedUnaryCall(getHeartbeatMethod(), responseObserver);
+ }
+
+ @Override public final io.grpc.ServerServiceDefinition bindService() {
+ return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
+ .addMethod(
+ getHeartbeatMethod(),
+ asyncUnaryCall(
+ new MethodHandlers<
+ Heartbeat,
+ Response>(
+ this, METHODID_HEARTBEAT)))
+ .build();
+ }
+ }
+
+ /**
+ */
+ public static final class HeartbeatServiceStub extends io.grpc.stub.AbstractStub {
+ private HeartbeatServiceStub(io.grpc.Channel channel) {
+ super(channel);
+ }
+
+ private HeartbeatServiceStub(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ super(channel, callOptions);
+ }
+
+ @Override
+ protected HeartbeatServiceStub build(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ return new HeartbeatServiceStub(channel, callOptions);
+ }
+
+ /**
+ */
+ public void heartbeat(Heartbeat request,
+ io.grpc.stub.StreamObserver responseObserver) {
+ asyncUnaryCall(
+ getChannel().newCall(getHeartbeatMethod(), getCallOptions()), request, responseObserver);
+ }
+ }
+
+ /**
+ */
+ public static final class HeartbeatServiceBlockingStub extends io.grpc.stub.AbstractStub {
+ private HeartbeatServiceBlockingStub(io.grpc.Channel channel) {
+ super(channel);
+ }
+
+ private HeartbeatServiceBlockingStub(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ super(channel, callOptions);
+ }
+
+ @Override
+ protected HeartbeatServiceBlockingStub build(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ return new HeartbeatServiceBlockingStub(channel, callOptions);
+ }
+
+ /**
+ */
+ public Response heartbeat(Heartbeat request) {
+ return blockingUnaryCall(
+ getChannel(), getHeartbeatMethod(), getCallOptions(), request);
+ }
+ }
+
+ /**
+ */
+ public static final class HeartbeatServiceFutureStub extends io.grpc.stub.AbstractStub {
+ private HeartbeatServiceFutureStub(io.grpc.Channel channel) {
+ super(channel);
+ }
+
+ private HeartbeatServiceFutureStub(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ super(channel, callOptions);
+ }
+
+ @Override
+ protected HeartbeatServiceFutureStub build(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ return new HeartbeatServiceFutureStub(channel, callOptions);
+ }
+
+ /**
+ */
+ public com.google.common.util.concurrent.ListenableFuture heartbeat(
+ Heartbeat request) {
+ return futureUnaryCall(
+ getChannel().newCall(getHeartbeatMethod(), getCallOptions()), request);
+ }
+ }
+
+ private static final int METHODID_HEARTBEAT = 0;
+
+ private static final class MethodHandlers implements
+ io.grpc.stub.ServerCalls.UnaryMethod,
+ io.grpc.stub.ServerCalls.ServerStreamingMethod,
+ io.grpc.stub.ServerCalls.ClientStreamingMethod,
+ io.grpc.stub.ServerCalls.BidiStreamingMethod {
+ private final HeartbeatServiceImplBase serviceImpl;
+ private final int methodId;
+
+ MethodHandlers(HeartbeatServiceImplBase serviceImpl, int methodId) {
+ this.serviceImpl = serviceImpl;
+ this.methodId = methodId;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) {
+ switch (methodId) {
+ case METHODID_HEARTBEAT:
+ serviceImpl.heartbeat((Heartbeat) request,
+ (io.grpc.stub.StreamObserver) responseObserver);
+ break;
+ default:
+ throw new AssertionError();
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public io.grpc.stub.StreamObserver invoke(
+ io.grpc.stub.StreamObserver responseObserver) {
+ switch (methodId) {
+ default:
+ throw new AssertionError();
+ }
+ }
+ }
+
+ private static abstract class HeartbeatServiceBaseDescriptorSupplier
+ implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
+ HeartbeatServiceBaseDescriptorSupplier() {}
+
+ @Override
+ public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
+ return EventmeshGrpc.getDescriptor();
+ }
+
+ @Override
+ public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
+ return getFileDescriptor().findServiceByName("HeartbeatService");
+ }
+ }
+
+ private static final class HeartbeatServiceFileDescriptorSupplier
+ extends HeartbeatServiceBaseDescriptorSupplier {
+ HeartbeatServiceFileDescriptorSupplier() {}
+ }
+
+ private static final class HeartbeatServiceMethodDescriptorSupplier
+ extends HeartbeatServiceBaseDescriptorSupplier
+ implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
+ private final String methodName;
+
+ HeartbeatServiceMethodDescriptorSupplier(String methodName) {
+ this.methodName = methodName;
+ }
+
+ @Override
+ public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
+ return getServiceDescriptor().findMethodByName(methodName);
+ }
+ }
+
+ private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
+
+ public static io.grpc.ServiceDescriptor getServiceDescriptor() {
+ io.grpc.ServiceDescriptor result = serviceDescriptor;
+ if (result == null) {
+ synchronized (HeartbeatServiceGrpc.class) {
+ result = serviceDescriptor;
+ if (result == null) {
+ serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
+ .setSchemaDescriptor(new HeartbeatServiceFileDescriptorSupplier())
+ .addMethod(getHeartbeatMethod())
+ .build();
+ }
+ }
+ }
+ return result;
+ }
+}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java
new file mode 100644
index 0000000000..c23bb07cc2
--- /dev/null
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/PublisherServiceGrpc.java
@@ -0,0 +1,430 @@
+package org.apache.eventmesh.common.protocol.grpc.protos;
+
+import static io.grpc.MethodDescriptor.generateFullMethodName;
+import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
+import static io.grpc.stub.ClientCalls.asyncUnaryCall;
+import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
+import static io.grpc.stub.ClientCalls.blockingUnaryCall;
+import static io.grpc.stub.ClientCalls.futureUnaryCall;
+import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncUnaryCall;
+import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
+import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
+
+/**
+ */
+@javax.annotation.Generated(
+ value = "by gRPC proto compiler (version 1.15.0)",
+ comments = "Source: eventmesh-client.proto")
+public final class PublisherServiceGrpc {
+
+ private PublisherServiceGrpc() {}
+
+ public static final String SERVICE_NAME = "eventmesh.common.protocol.grpc.PublisherService";
+
+ // Static method descriptors that strictly reflect the proto.
+ private static volatile io.grpc.MethodDescriptor getPublishMethod;
+
+ @io.grpc.stub.annotations.RpcMethod(
+ fullMethodName = SERVICE_NAME + '/' + "publish",
+ requestType = EventMeshMessage.class,
+ responseType = Response.class,
+ methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
+ public static io.grpc.MethodDescriptor getPublishMethod() {
+ io.grpc.MethodDescriptor getPublishMethod;
+ if ((getPublishMethod = PublisherServiceGrpc.getPublishMethod) == null) {
+ synchronized (PublisherServiceGrpc.class) {
+ if ((getPublishMethod = PublisherServiceGrpc.getPublishMethod) == null) {
+ PublisherServiceGrpc.getPublishMethod = getPublishMethod =
+ io.grpc.MethodDescriptor.newBuilder()
+ .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName(generateFullMethodName(
+ "eventmesh.common.protocol.grpc.PublisherService", "publish"))
+ .setSampledToLocalTracing(true)
+ .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+ EventMeshMessage.getDefaultInstance()))
+ .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+ Response.getDefaultInstance()))
+ .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("publish"))
+ .build();
+ }
+ }
+ }
+ return getPublishMethod;
+ }
+
+ private static volatile io.grpc.MethodDescriptor getRequestReplyMethod;
+
+ @io.grpc.stub.annotations.RpcMethod(
+ fullMethodName = SERVICE_NAME + '/' + "requestReply",
+ requestType = EventMeshMessage.class,
+ responseType = Response.class,
+ methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
+ public static io.grpc.MethodDescriptor getRequestReplyMethod() {
+ io.grpc.MethodDescriptor getRequestReplyMethod;
+ if ((getRequestReplyMethod = PublisherServiceGrpc.getRequestReplyMethod) == null) {
+ synchronized (PublisherServiceGrpc.class) {
+ if ((getRequestReplyMethod = PublisherServiceGrpc.getRequestReplyMethod) == null) {
+ PublisherServiceGrpc.getRequestReplyMethod = getRequestReplyMethod =
+ io.grpc.MethodDescriptor.newBuilder()
+ .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName(generateFullMethodName(
+ "eventmesh.common.protocol.grpc.PublisherService", "requestReply"))
+ .setSampledToLocalTracing(true)
+ .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+ EventMeshMessage.getDefaultInstance()))
+ .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+ Response.getDefaultInstance()))
+ .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("requestReply"))
+ .build();
+ }
+ }
+ }
+ return getRequestReplyMethod;
+ }
+
+ private static volatile io.grpc.MethodDescriptor getBroadcastMethod;
+
+ @io.grpc.stub.annotations.RpcMethod(
+ fullMethodName = SERVICE_NAME + '/' + "broadcast",
+ requestType = EventMeshMessage.class,
+ responseType = Response.class,
+ methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
+ public static io.grpc.MethodDescriptor getBroadcastMethod() {
+ io.grpc.MethodDescriptor getBroadcastMethod;
+ if ((getBroadcastMethod = PublisherServiceGrpc.getBroadcastMethod) == null) {
+ synchronized (PublisherServiceGrpc.class) {
+ if ((getBroadcastMethod = PublisherServiceGrpc.getBroadcastMethod) == null) {
+ PublisherServiceGrpc.getBroadcastMethod = getBroadcastMethod =
+ io.grpc.MethodDescriptor.newBuilder()
+ .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName(generateFullMethodName(
+ "eventmesh.common.protocol.grpc.PublisherService", "broadcast"))
+ .setSampledToLocalTracing(true)
+ .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+ EventMeshMessage.getDefaultInstance()))
+ .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
+ Response.getDefaultInstance()))
+ .setSchemaDescriptor(new PublisherServiceMethodDescriptorSupplier("broadcast"))
+ .build();
+ }
+ }
+ }
+ return getBroadcastMethod;
+ }
+
+ /**
+ * Creates a new async stub that supports all call types for the service
+ */
+ public static PublisherServiceStub newStub(io.grpc.Channel channel) {
+ return new PublisherServiceStub(channel);
+ }
+
+ /**
+ * Creates a new blocking-style stub that supports unary and streaming output calls on the service
+ */
+ public static PublisherServiceBlockingStub newBlockingStub(
+ io.grpc.Channel channel) {
+ return new PublisherServiceBlockingStub(channel);
+ }
+
+ /**
+ * Creates a new ListenableFuture-style stub that supports unary calls on the service
+ */
+ public static PublisherServiceFutureStub newFutureStub(
+ io.grpc.Channel channel) {
+ return new PublisherServiceFutureStub(channel);
+ }
+
+ /**
+ */
+ public static abstract class PublisherServiceImplBase implements io.grpc.BindableService {
+
+ /**
+ */
+ public void publish(EventMeshMessage request,
+ io.grpc.stub.StreamObserver responseObserver) {
+ asyncUnimplementedUnaryCall(getPublishMethod(), responseObserver);
+ }
+
+ /**
+ */
+ public void requestReply(EventMeshMessage request,
+ io.grpc.stub.StreamObserver responseObserver) {
+ asyncUnimplementedUnaryCall(getRequestReplyMethod(), responseObserver);
+ }
+
+ /**
+ */
+ public void broadcast(EventMeshMessage request,
+ io.grpc.stub.StreamObserver responseObserver) {
+ asyncUnimplementedUnaryCall(getBroadcastMethod(), responseObserver);
+ }
+
+ @Override public final io.grpc.ServerServiceDefinition bindService() {
+ return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
+ .addMethod(
+ getPublishMethod(),
+ asyncUnaryCall(
+ new MethodHandlers<
+ EventMeshMessage,
+ Response>(
+ this, METHODID_PUBLISH)))
+ .addMethod(
+ getRequestReplyMethod(),
+ asyncUnaryCall(
+ new MethodHandlers<
+ EventMeshMessage,
+ Response>(
+ this, METHODID_REQUEST_REPLY)))
+ .addMethod(
+ getBroadcastMethod(),
+ asyncUnaryCall(
+ new MethodHandlers<
+ EventMeshMessage,
+ Response>(
+ this, METHODID_BROADCAST)))
+ .build();
+ }
+ }
+
+ /**
+ */
+ public static final class PublisherServiceStub extends io.grpc.stub.AbstractStub {
+ private PublisherServiceStub(io.grpc.Channel channel) {
+ super(channel);
+ }
+
+ private PublisherServiceStub(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ super(channel, callOptions);
+ }
+
+ @Override
+ protected PublisherServiceStub build(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ return new PublisherServiceStub(channel, callOptions);
+ }
+
+ /**
+ */
+ public void publish(EventMeshMessage request,
+ io.grpc.stub.StreamObserver responseObserver) {
+ asyncUnaryCall(
+ getChannel().newCall(getPublishMethod(), getCallOptions()), request, responseObserver);
+ }
+
+ /**
+ */
+ public void requestReply(EventMeshMessage request,
+ io.grpc.stub.StreamObserver responseObserver) {
+ asyncUnaryCall(
+ getChannel().newCall(getRequestReplyMethod(), getCallOptions()), request, responseObserver);
+ }
+
+ /**
+ */
+ public void broadcast(EventMeshMessage request,
+ io.grpc.stub.StreamObserver responseObserver) {
+ asyncUnaryCall(
+ getChannel().newCall(getBroadcastMethod(), getCallOptions()), request, responseObserver);
+ }
+ }
+
+ /**
+ */
+ public static final class PublisherServiceBlockingStub extends io.grpc.stub.AbstractStub {
+ private PublisherServiceBlockingStub(io.grpc.Channel channel) {
+ super(channel);
+ }
+
+ private PublisherServiceBlockingStub(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ super(channel, callOptions);
+ }
+
+ @Override
+ protected PublisherServiceBlockingStub build(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ return new PublisherServiceBlockingStub(channel, callOptions);
+ }
+
+ /**
+ */
+ public Response publish(EventMeshMessage request) {
+ return blockingUnaryCall(
+ getChannel(), getPublishMethod(), getCallOptions(), request);
+ }
+
+ /**
+ */
+ public Response requestReply(EventMeshMessage request) {
+ return blockingUnaryCall(
+ getChannel(), getRequestReplyMethod(), getCallOptions(), request);
+ }
+
+ /**
+ */
+ public Response broadcast(EventMeshMessage request) {
+ return blockingUnaryCall(
+ getChannel(), getBroadcastMethod(), getCallOptions(), request);
+ }
+ }
+
+ /**
+ */
+ public static final class PublisherServiceFutureStub extends io.grpc.stub.AbstractStub {
+ private PublisherServiceFutureStub(io.grpc.Channel channel) {
+ super(channel);
+ }
+
+ private PublisherServiceFutureStub(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ super(channel, callOptions);
+ }
+
+ @Override
+ protected PublisherServiceFutureStub build(io.grpc.Channel channel,
+ io.grpc.CallOptions callOptions) {
+ return new PublisherServiceFutureStub(channel, callOptions);
+ }
+
+ /**
+ */
+ public com.google.common.util.concurrent.ListenableFuture publish(
+ EventMeshMessage request) {
+ return futureUnaryCall(
+ getChannel().newCall(getPublishMethod(), getCallOptions()), request);
+ }
+
+ /**
+ */
+ public com.google.common.util.concurrent.ListenableFuture requestReply(
+ EventMeshMessage request) {
+ return futureUnaryCall(
+ getChannel().newCall(getRequestReplyMethod(), getCallOptions()), request);
+ }
+
+ /**
+ */
+ public com.google.common.util.concurrent.ListenableFuture broadcast(
+ EventMeshMessage request) {
+ return futureUnaryCall(
+ getChannel().newCall(getBroadcastMethod(), getCallOptions()), request);
+ }
+ }
+
+ private static final int METHODID_PUBLISH = 0;
+ private static final int METHODID_REQUEST_REPLY = 1;
+ private static final int METHODID_BROADCAST = 2;
+
+ private static final class MethodHandlers implements
+ io.grpc.stub.ServerCalls.UnaryMethod,
+ io.grpc.stub.ServerCalls.ServerStreamingMethod,
+ io.grpc.stub.ServerCalls.ClientStreamingMethod,
+ io.grpc.stub.ServerCalls.BidiStreamingMethod {
+ private final PublisherServiceImplBase serviceImpl;
+ private final int methodId;
+
+ MethodHandlers(PublisherServiceImplBase serviceImpl, int methodId) {
+ this.serviceImpl = serviceImpl;
+ this.methodId = methodId;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) {
+ switch (methodId) {
+ case METHODID_PUBLISH:
+ serviceImpl.publish((EventMeshMessage) request,
+ (io.grpc.stub.StreamObserver) responseObserver);
+ break;
+ case METHODID_REQUEST_REPLY:
+ serviceImpl.requestReply((EventMeshMessage) request,
+ (io.grpc.stub.StreamObserver) responseObserver);
+ break;
+ case METHODID_BROADCAST:
+ serviceImpl.broadcast((EventMeshMessage) request,
+ (io.grpc.stub.StreamObserver) responseObserver);
+ break;
+ default:
+ throw new AssertionError();
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public io.grpc.stub.StreamObserver invoke(
+ io.grpc.stub.StreamObserver responseObserver) {
+ switch (methodId) {
+ default:
+ throw new AssertionError();
+ }
+ }
+ }
+
+ private static abstract class PublisherServiceBaseDescriptorSupplier
+ implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
+ PublisherServiceBaseDescriptorSupplier() {}
+
+ @Override
+ public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
+ return EventmeshGrpc.getDescriptor();
+ }
+
+ @Override
+ public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
+ return getFileDescriptor().findServiceByName("PublisherService");
+ }
+ }
+
+ private static final class PublisherServiceFileDescriptorSupplier
+ extends PublisherServiceBaseDescriptorSupplier {
+ PublisherServiceFileDescriptorSupplier() {}
+ }
+
+ private static final class PublisherServiceMethodDescriptorSupplier
+ extends PublisherServiceBaseDescriptorSupplier
+ implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
+ private final String methodName;
+
+ PublisherServiceMethodDescriptorSupplier(String methodName) {
+ this.methodName = methodName;
+ }
+
+ @Override
+ public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
+ return getServiceDescriptor().findMethodByName(methodName);
+ }
+ }
+
+ private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
+
+ public static io.grpc.ServiceDescriptor getServiceDescriptor() {
+ io.grpc.ServiceDescriptor result = serviceDescriptor;
+ if (result == null) {
+ synchronized (PublisherServiceGrpc.class) {
+ result = serviceDescriptor;
+ if (result == null) {
+ serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
+ .setSchemaDescriptor(new PublisherServiceFileDescriptorSupplier())
+ .addMethod(getPublishMethod())
+ .addMethod(getRequestReplyMethod())
+ .addMethod(getBroadcastMethod())
+ .build();
+ }
+ }
+ }
+ return result;
+ }
+}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java
new file mode 100644
index 0000000000..d53cbcbfef
--- /dev/null
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeader.java
@@ -0,0 +1,1913 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: eventmesh-client.proto
+
+package org.apache.eventmesh.common.protocol.grpc.protos;
+
+/**
+ * Protobuf type {@code eventmesh.common.protocol.grpc.RequestHeader}
+ */
+public final class RequestHeader extends
+ com.google.protobuf.GeneratedMessageV3 implements
+ // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.RequestHeader)
+ RequestHeaderOrBuilder {
+private static final long serialVersionUID = 0L;
+ // Use RequestHeader.newBuilder() to construct.
+ private RequestHeader(com.google.protobuf.GeneratedMessageV3.Builder> builder) {
+ super(builder);
+ }
+ private RequestHeader() {
+ env_ = "";
+ region_ = "";
+ idc_ = "";
+ ip_ = "";
+ pid_ = "";
+ sys_ = "";
+ username_ = "";
+ password_ = "";
+ language_ = "";
+ protocolType_ = "";
+ protocolVersion_ = "";
+ protocolDesc_ = "";
+ }
+
+ @Override
+ public final com.google.protobuf.UnknownFieldSet
+ getUnknownFields() {
+ return this.unknownFields;
+ }
+ private RequestHeader(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ this();
+ if (extensionRegistry == null) {
+ throw new NullPointerException();
+ }
+ int mutable_bitField0_ = 0;
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder();
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ default: {
+ if (!parseUnknownFieldProto3(
+ input, unknownFields, extensionRegistry, tag)) {
+ done = true;
+ }
+ break;
+ }
+ case 10: {
+ String s = input.readStringRequireUtf8();
+
+ env_ = s;
+ break;
+ }
+ case 18: {
+ String s = input.readStringRequireUtf8();
+
+ region_ = s;
+ break;
+ }
+ case 26: {
+ String s = input.readStringRequireUtf8();
+
+ idc_ = s;
+ break;
+ }
+ case 34: {
+ String s = input.readStringRequireUtf8();
+
+ ip_ = s;
+ break;
+ }
+ case 42: {
+ String s = input.readStringRequireUtf8();
+
+ pid_ = s;
+ break;
+ }
+ case 50: {
+ String s = input.readStringRequireUtf8();
+
+ sys_ = s;
+ break;
+ }
+ case 58: {
+ String s = input.readStringRequireUtf8();
+
+ username_ = s;
+ break;
+ }
+ case 66: {
+ String s = input.readStringRequireUtf8();
+
+ password_ = s;
+ break;
+ }
+ case 74: {
+ String s = input.readStringRequireUtf8();
+
+ language_ = s;
+ break;
+ }
+ case 82: {
+ String s = input.readStringRequireUtf8();
+
+ protocolType_ = s;
+ break;
+ }
+ case 90: {
+ String s = input.readStringRequireUtf8();
+
+ protocolVersion_ = s;
+ break;
+ }
+ case 98: {
+ String s = input.readStringRequireUtf8();
+
+ protocolDesc_ = s;
+ break;
+ }
+ }
+ }
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(this);
+ } catch (java.io.IOException e) {
+ throw new com.google.protobuf.InvalidProtocolBufferException(
+ e).setUnfinishedMessage(this);
+ } finally {
+ this.unknownFields = unknownFields.build();
+ makeExtensionsImmutable();
+ }
+ }
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_RequestHeader_descriptor;
+ }
+
+ protected FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_RequestHeader_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ RequestHeader.class, Builder.class);
+ }
+
+ public static final int ENV_FIELD_NUMBER = 1;
+ private volatile Object env_;
+ /**
+ * string env = 1;
+ */
+ public String getEnv() {
+ Object ref = env_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ env_ = s;
+ return s;
+ }
+ }
+ /**
+ * string env = 1;
+ */
+ public com.google.protobuf.ByteString
+ getEnvBytes() {
+ Object ref = env_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ env_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int REGION_FIELD_NUMBER = 2;
+ private volatile Object region_;
+ /**
+ * string region = 2;
+ */
+ public String getRegion() {
+ Object ref = region_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ region_ = s;
+ return s;
+ }
+ }
+ /**
+ * string region = 2;
+ */
+ public com.google.protobuf.ByteString
+ getRegionBytes() {
+ Object ref = region_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ region_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int IDC_FIELD_NUMBER = 3;
+ private volatile Object idc_;
+ /**
+ * string idc = 3;
+ */
+ public String getIdc() {
+ Object ref = idc_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ idc_ = s;
+ return s;
+ }
+ }
+ /**
+ * string idc = 3;
+ */
+ public com.google.protobuf.ByteString
+ getIdcBytes() {
+ Object ref = idc_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ idc_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int IP_FIELD_NUMBER = 4;
+ private volatile Object ip_;
+ /**
+ * string ip = 4;
+ */
+ public String getIp() {
+ Object ref = ip_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ ip_ = s;
+ return s;
+ }
+ }
+ /**
+ * string ip = 4;
+ */
+ public com.google.protobuf.ByteString
+ getIpBytes() {
+ Object ref = ip_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ ip_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int PID_FIELD_NUMBER = 5;
+ private volatile Object pid_;
+ /**
+ * string pid = 5;
+ */
+ public String getPid() {
+ Object ref = pid_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ pid_ = s;
+ return s;
+ }
+ }
+ /**
+ * string pid = 5;
+ */
+ public com.google.protobuf.ByteString
+ getPidBytes() {
+ Object ref = pid_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ pid_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int SYS_FIELD_NUMBER = 6;
+ private volatile Object sys_;
+ /**
+ * string sys = 6;
+ */
+ public String getSys() {
+ Object ref = sys_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ sys_ = s;
+ return s;
+ }
+ }
+ /**
+ * string sys = 6;
+ */
+ public com.google.protobuf.ByteString
+ getSysBytes() {
+ Object ref = sys_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ sys_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int USERNAME_FIELD_NUMBER = 7;
+ private volatile Object username_;
+ /**
+ * string username = 7;
+ */
+ public String getUsername() {
+ Object ref = username_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ username_ = s;
+ return s;
+ }
+ }
+ /**
+ * string username = 7;
+ */
+ public com.google.protobuf.ByteString
+ getUsernameBytes() {
+ Object ref = username_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ username_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int PASSWORD_FIELD_NUMBER = 8;
+ private volatile Object password_;
+ /**
+ * string password = 8;
+ */
+ public String getPassword() {
+ Object ref = password_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ password_ = s;
+ return s;
+ }
+ }
+ /**
+ * string password = 8;
+ */
+ public com.google.protobuf.ByteString
+ getPasswordBytes() {
+ Object ref = password_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ password_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int LANGUAGE_FIELD_NUMBER = 9;
+ private volatile Object language_;
+ /**
+ * string language = 9;
+ */
+ public String getLanguage() {
+ Object ref = language_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ language_ = s;
+ return s;
+ }
+ }
+ /**
+ * string language = 9;
+ */
+ public com.google.protobuf.ByteString
+ getLanguageBytes() {
+ Object ref = language_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ language_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int PROTOCOLTYPE_FIELD_NUMBER = 10;
+ private volatile Object protocolType_;
+ /**
+ * string protocolType = 10;
+ */
+ public String getProtocolType() {
+ Object ref = protocolType_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ protocolType_ = s;
+ return s;
+ }
+ }
+ /**
+ * string protocolType = 10;
+ */
+ public com.google.protobuf.ByteString
+ getProtocolTypeBytes() {
+ Object ref = protocolType_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ protocolType_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int PROTOCOLVERSION_FIELD_NUMBER = 11;
+ private volatile Object protocolVersion_;
+ /**
+ * string protocolVersion = 11;
+ */
+ public String getProtocolVersion() {
+ Object ref = protocolVersion_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ protocolVersion_ = s;
+ return s;
+ }
+ }
+ /**
+ * string protocolVersion = 11;
+ */
+ public com.google.protobuf.ByteString
+ getProtocolVersionBytes() {
+ Object ref = protocolVersion_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ protocolVersion_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int PROTOCOLDESC_FIELD_NUMBER = 12;
+ private volatile Object protocolDesc_;
+ /**
+ * string protocolDesc = 12;
+ */
+ public String getProtocolDesc() {
+ Object ref = protocolDesc_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ protocolDesc_ = s;
+ return s;
+ }
+ }
+ /**
+ * string protocolDesc = 12;
+ */
+ public com.google.protobuf.ByteString
+ getProtocolDescBytes() {
+ Object ref = protocolDesc_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ protocolDesc_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized == 1) return true;
+ if (isInitialized == 0) return false;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ if (!getEnvBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 1, env_);
+ }
+ if (!getRegionBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 2, region_);
+ }
+ if (!getIdcBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 3, idc_);
+ }
+ if (!getIpBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 4, ip_);
+ }
+ if (!getPidBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 5, pid_);
+ }
+ if (!getSysBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 6, sys_);
+ }
+ if (!getUsernameBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 7, username_);
+ }
+ if (!getPasswordBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 8, password_);
+ }
+ if (!getLanguageBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 9, language_);
+ }
+ if (!getProtocolTypeBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 10, protocolType_);
+ }
+ if (!getProtocolVersionBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 11, protocolVersion_);
+ }
+ if (!getProtocolDescBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 12, protocolDesc_);
+ }
+ unknownFields.writeTo(output);
+ }
+
+ public int getSerializedSize() {
+ int size = memoizedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (!getEnvBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, env_);
+ }
+ if (!getRegionBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, region_);
+ }
+ if (!getIdcBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, idc_);
+ }
+ if (!getIpBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, ip_);
+ }
+ if (!getPidBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, pid_);
+ }
+ if (!getSysBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, sys_);
+ }
+ if (!getUsernameBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, username_);
+ }
+ if (!getPasswordBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, password_);
+ }
+ if (!getLanguageBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, language_);
+ }
+ if (!getProtocolTypeBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(10, protocolType_);
+ }
+ if (!getProtocolVersionBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(11, protocolVersion_);
+ }
+ if (!getProtocolDescBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(12, protocolDesc_);
+ }
+ size += unknownFields.getSerializedSize();
+ memoizedSize = size;
+ return size;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof RequestHeader)) {
+ return super.equals(obj);
+ }
+ RequestHeader other = (RequestHeader) obj;
+
+ boolean result = true;
+ result = result && getEnv()
+ .equals(other.getEnv());
+ result = result && getRegion()
+ .equals(other.getRegion());
+ result = result && getIdc()
+ .equals(other.getIdc());
+ result = result && getIp()
+ .equals(other.getIp());
+ result = result && getPid()
+ .equals(other.getPid());
+ result = result && getSys()
+ .equals(other.getSys());
+ result = result && getUsername()
+ .equals(other.getUsername());
+ result = result && getPassword()
+ .equals(other.getPassword());
+ result = result && getLanguage()
+ .equals(other.getLanguage());
+ result = result && getProtocolType()
+ .equals(other.getProtocolType());
+ result = result && getProtocolVersion()
+ .equals(other.getProtocolVersion());
+ result = result && getProtocolDesc()
+ .equals(other.getProtocolDesc());
+ result = result && unknownFields.equals(other.unknownFields);
+ return result;
+ }
+
+ @Override
+ public int hashCode() {
+ if (memoizedHashCode != 0) {
+ return memoizedHashCode;
+ }
+ int hash = 41;
+ hash = (19 * hash) + getDescriptor().hashCode();
+ hash = (37 * hash) + ENV_FIELD_NUMBER;
+ hash = (53 * hash) + getEnv().hashCode();
+ hash = (37 * hash) + REGION_FIELD_NUMBER;
+ hash = (53 * hash) + getRegion().hashCode();
+ hash = (37 * hash) + IDC_FIELD_NUMBER;
+ hash = (53 * hash) + getIdc().hashCode();
+ hash = (37 * hash) + IP_FIELD_NUMBER;
+ hash = (53 * hash) + getIp().hashCode();
+ hash = (37 * hash) + PID_FIELD_NUMBER;
+ hash = (53 * hash) + getPid().hashCode();
+ hash = (37 * hash) + SYS_FIELD_NUMBER;
+ hash = (53 * hash) + getSys().hashCode();
+ hash = (37 * hash) + USERNAME_FIELD_NUMBER;
+ hash = (53 * hash) + getUsername().hashCode();
+ hash = (37 * hash) + PASSWORD_FIELD_NUMBER;
+ hash = (53 * hash) + getPassword().hashCode();
+ hash = (37 * hash) + LANGUAGE_FIELD_NUMBER;
+ hash = (53 * hash) + getLanguage().hashCode();
+ hash = (37 * hash) + PROTOCOLTYPE_FIELD_NUMBER;
+ hash = (53 * hash) + getProtocolType().hashCode();
+ hash = (37 * hash) + PROTOCOLVERSION_FIELD_NUMBER;
+ hash = (53 * hash) + getProtocolVersion().hashCode();
+ hash = (37 * hash) + PROTOCOLDESC_FIELD_NUMBER;
+ hash = (53 * hash) + getProtocolDesc().hashCode();
+ hash = (29 * hash) + unknownFields.hashCode();
+ memoizedHashCode = hash;
+ return hash;
+ }
+
+ public static RequestHeader parseFrom(
+ java.nio.ByteBuffer data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static RequestHeader parseFrom(
+ java.nio.ByteBuffer data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static RequestHeader parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static RequestHeader parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static RequestHeader parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static RequestHeader parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static RequestHeader parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static RequestHeader parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static RequestHeader parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input);
+ }
+ public static RequestHeader parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static RequestHeader parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static RequestHeader parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder() {
+ return DEFAULT_INSTANCE.toBuilder();
+ }
+ public static Builder newBuilder(RequestHeader prototype) {
+ return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() {
+ return this == DEFAULT_INSTANCE
+ ? new Builder() : new Builder().mergeFrom(this);
+ }
+
+ @Override
+ protected Builder newBuilderForType(
+ BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ * Protobuf type {@code eventmesh.common.protocol.grpc.RequestHeader}
+ */
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessageV3.Builder implements
+ // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.RequestHeader)
+ RequestHeaderOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_RequestHeader_descriptor;
+ }
+
+ protected FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_RequestHeader_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ RequestHeader.class, Builder.class);
+ }
+
+ // Construct using org.apache.eventmesh.common.protocol.grpc.protos.RequestHeader.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(
+ BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessageV3
+ .alwaysUseFieldBuilders) {
+ }
+ }
+ public Builder clear() {
+ super.clear();
+ env_ = "";
+
+ region_ = "";
+
+ idc_ = "";
+
+ ip_ = "";
+
+ pid_ = "";
+
+ sys_ = "";
+
+ username_ = "";
+
+ password_ = "";
+
+ language_ = "";
+
+ protocolType_ = "";
+
+ protocolVersion_ = "";
+
+ protocolDesc_ = "";
+
+ return this;
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_RequestHeader_descriptor;
+ }
+
+ public RequestHeader getDefaultInstanceForType() {
+ return RequestHeader.getDefaultInstance();
+ }
+
+ public RequestHeader build() {
+ RequestHeader result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ public RequestHeader buildPartial() {
+ RequestHeader result = new RequestHeader(this);
+ result.env_ = env_;
+ result.region_ = region_;
+ result.idc_ = idc_;
+ result.ip_ = ip_;
+ result.pid_ = pid_;
+ result.sys_ = sys_;
+ result.username_ = username_;
+ result.password_ = password_;
+ result.language_ = language_;
+ result.protocolType_ = protocolType_;
+ result.protocolVersion_ = protocolVersion_;
+ result.protocolDesc_ = protocolDesc_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder clone() {
+ return (Builder) super.clone();
+ }
+ public Builder setField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ Object value) {
+ return (Builder) super.setField(field, value);
+ }
+ public Builder clearField(
+ com.google.protobuf.Descriptors.FieldDescriptor field) {
+ return (Builder) super.clearField(field);
+ }
+ public Builder clearOneof(
+ com.google.protobuf.Descriptors.OneofDescriptor oneof) {
+ return (Builder) super.clearOneof(oneof);
+ }
+ public Builder setRepeatedField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ int index, Object value) {
+ return (Builder) super.setRepeatedField(field, index, value);
+ }
+ public Builder addRepeatedField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ Object value) {
+ return (Builder) super.addRepeatedField(field, value);
+ }
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof RequestHeader) {
+ return mergeFrom((RequestHeader)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(RequestHeader other) {
+ if (other == RequestHeader.getDefaultInstance()) return this;
+ if (!other.getEnv().isEmpty()) {
+ env_ = other.env_;
+ onChanged();
+ }
+ if (!other.getRegion().isEmpty()) {
+ region_ = other.region_;
+ onChanged();
+ }
+ if (!other.getIdc().isEmpty()) {
+ idc_ = other.idc_;
+ onChanged();
+ }
+ if (!other.getIp().isEmpty()) {
+ ip_ = other.ip_;
+ onChanged();
+ }
+ if (!other.getPid().isEmpty()) {
+ pid_ = other.pid_;
+ onChanged();
+ }
+ if (!other.getSys().isEmpty()) {
+ sys_ = other.sys_;
+ onChanged();
+ }
+ if (!other.getUsername().isEmpty()) {
+ username_ = other.username_;
+ onChanged();
+ }
+ if (!other.getPassword().isEmpty()) {
+ password_ = other.password_;
+ onChanged();
+ }
+ if (!other.getLanguage().isEmpty()) {
+ language_ = other.language_;
+ onChanged();
+ }
+ if (!other.getProtocolType().isEmpty()) {
+ protocolType_ = other.protocolType_;
+ onChanged();
+ }
+ if (!other.getProtocolVersion().isEmpty()) {
+ protocolVersion_ = other.protocolVersion_;
+ onChanged();
+ }
+ if (!other.getProtocolDesc().isEmpty()) {
+ protocolDesc_ = other.protocolDesc_;
+ onChanged();
+ }
+ this.mergeUnknownFields(other.unknownFields);
+ onChanged();
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ RequestHeader parsedMessage = null;
+ try {
+ parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ parsedMessage = (RequestHeader) e.getUnfinishedMessage();
+ throw e.unwrapIOException();
+ } finally {
+ if (parsedMessage != null) {
+ mergeFrom(parsedMessage);
+ }
+ }
+ return this;
+ }
+
+ private Object env_ = "";
+ /**
+ * string env = 1;
+ */
+ public String getEnv() {
+ Object ref = env_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ env_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string env = 1;
+ */
+ public com.google.protobuf.ByteString
+ getEnvBytes() {
+ Object ref = env_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ env_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string env = 1;
+ */
+ public Builder setEnv(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ env_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string env = 1;
+ */
+ public Builder clearEnv() {
+
+ env_ = getDefaultInstance().getEnv();
+ onChanged();
+ return this;
+ }
+ /**
+ * string env = 1;
+ */
+ public Builder setEnvBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ env_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object region_ = "";
+ /**
+ * string region = 2;
+ */
+ public String getRegion() {
+ Object ref = region_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ region_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string region = 2;
+ */
+ public com.google.protobuf.ByteString
+ getRegionBytes() {
+ Object ref = region_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ region_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string region = 2;
+ */
+ public Builder setRegion(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ region_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string region = 2;
+ */
+ public Builder clearRegion() {
+
+ region_ = getDefaultInstance().getRegion();
+ onChanged();
+ return this;
+ }
+ /**
+ * string region = 2;
+ */
+ public Builder setRegionBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ region_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object idc_ = "";
+ /**
+ * string idc = 3;
+ */
+ public String getIdc() {
+ Object ref = idc_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ idc_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string idc = 3;
+ */
+ public com.google.protobuf.ByteString
+ getIdcBytes() {
+ Object ref = idc_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ idc_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string idc = 3;
+ */
+ public Builder setIdc(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ idc_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string idc = 3;
+ */
+ public Builder clearIdc() {
+
+ idc_ = getDefaultInstance().getIdc();
+ onChanged();
+ return this;
+ }
+ /**
+ * string idc = 3;
+ */
+ public Builder setIdcBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ idc_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object ip_ = "";
+ /**
+ * string ip = 4;
+ */
+ public String getIp() {
+ Object ref = ip_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ ip_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string ip = 4;
+ */
+ public com.google.protobuf.ByteString
+ getIpBytes() {
+ Object ref = ip_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ ip_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string ip = 4;
+ */
+ public Builder setIp(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ ip_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string ip = 4;
+ */
+ public Builder clearIp() {
+
+ ip_ = getDefaultInstance().getIp();
+ onChanged();
+ return this;
+ }
+ /**
+ * string ip = 4;
+ */
+ public Builder setIpBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ ip_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object pid_ = "";
+ /**
+ * string pid = 5;
+ */
+ public String getPid() {
+ Object ref = pid_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ pid_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string pid = 5;
+ */
+ public com.google.protobuf.ByteString
+ getPidBytes() {
+ Object ref = pid_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ pid_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string pid = 5;
+ */
+ public Builder setPid(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ pid_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string pid = 5;
+ */
+ public Builder clearPid() {
+
+ pid_ = getDefaultInstance().getPid();
+ onChanged();
+ return this;
+ }
+ /**
+ * string pid = 5;
+ */
+ public Builder setPidBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ pid_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object sys_ = "";
+ /**
+ * string sys = 6;
+ */
+ public String getSys() {
+ Object ref = sys_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ sys_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string sys = 6;
+ */
+ public com.google.protobuf.ByteString
+ getSysBytes() {
+ Object ref = sys_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ sys_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string sys = 6;
+ */
+ public Builder setSys(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ sys_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string sys = 6;
+ */
+ public Builder clearSys() {
+
+ sys_ = getDefaultInstance().getSys();
+ onChanged();
+ return this;
+ }
+ /**
+ * string sys = 6;
+ */
+ public Builder setSysBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ sys_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object username_ = "";
+ /**
+ * string username = 7;
+ */
+ public String getUsername() {
+ Object ref = username_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ username_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string username = 7;
+ */
+ public com.google.protobuf.ByteString
+ getUsernameBytes() {
+ Object ref = username_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ username_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string username = 7;
+ */
+ public Builder setUsername(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ username_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string username = 7;
+ */
+ public Builder clearUsername() {
+
+ username_ = getDefaultInstance().getUsername();
+ onChanged();
+ return this;
+ }
+ /**
+ * string username = 7;
+ */
+ public Builder setUsernameBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ username_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object password_ = "";
+ /**
+ * string password = 8;
+ */
+ public String getPassword() {
+ Object ref = password_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ password_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string password = 8;
+ */
+ public com.google.protobuf.ByteString
+ getPasswordBytes() {
+ Object ref = password_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ password_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string password = 8;
+ */
+ public Builder setPassword(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ password_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string password = 8;
+ */
+ public Builder clearPassword() {
+
+ password_ = getDefaultInstance().getPassword();
+ onChanged();
+ return this;
+ }
+ /**
+ * string password = 8;
+ */
+ public Builder setPasswordBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ password_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object language_ = "";
+ /**
+ * string language = 9;
+ */
+ public String getLanguage() {
+ Object ref = language_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ language_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string language = 9;
+ */
+ public com.google.protobuf.ByteString
+ getLanguageBytes() {
+ Object ref = language_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ language_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string language = 9;
+ */
+ public Builder setLanguage(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ language_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string language = 9;
+ */
+ public Builder clearLanguage() {
+
+ language_ = getDefaultInstance().getLanguage();
+ onChanged();
+ return this;
+ }
+ /**
+ * string language = 9;
+ */
+ public Builder setLanguageBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ language_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object protocolType_ = "";
+ /**
+ * string protocolType = 10;
+ */
+ public String getProtocolType() {
+ Object ref = protocolType_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ protocolType_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string protocolType = 10;
+ */
+ public com.google.protobuf.ByteString
+ getProtocolTypeBytes() {
+ Object ref = protocolType_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ protocolType_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string protocolType = 10;
+ */
+ public Builder setProtocolType(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ protocolType_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string protocolType = 10;
+ */
+ public Builder clearProtocolType() {
+
+ protocolType_ = getDefaultInstance().getProtocolType();
+ onChanged();
+ return this;
+ }
+ /**
+ * string protocolType = 10;
+ */
+ public Builder setProtocolTypeBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ protocolType_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object protocolVersion_ = "";
+ /**
+ * string protocolVersion = 11;
+ */
+ public String getProtocolVersion() {
+ Object ref = protocolVersion_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ protocolVersion_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string protocolVersion = 11;
+ */
+ public com.google.protobuf.ByteString
+ getProtocolVersionBytes() {
+ Object ref = protocolVersion_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ protocolVersion_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string protocolVersion = 11;
+ */
+ public Builder setProtocolVersion(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ protocolVersion_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string protocolVersion = 11;
+ */
+ public Builder clearProtocolVersion() {
+
+ protocolVersion_ = getDefaultInstance().getProtocolVersion();
+ onChanged();
+ return this;
+ }
+ /**
+ * string protocolVersion = 11;
+ */
+ public Builder setProtocolVersionBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ protocolVersion_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object protocolDesc_ = "";
+ /**
+ * string protocolDesc = 12;
+ */
+ public String getProtocolDesc() {
+ Object ref = protocolDesc_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ protocolDesc_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string protocolDesc = 12;
+ */
+ public com.google.protobuf.ByteString
+ getProtocolDescBytes() {
+ Object ref = protocolDesc_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ protocolDesc_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string protocolDesc = 12;
+ */
+ public Builder setProtocolDesc(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ protocolDesc_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string protocolDesc = 12;
+ */
+ public Builder clearProtocolDesc() {
+
+ protocolDesc_ = getDefaultInstance().getProtocolDesc();
+ onChanged();
+ return this;
+ }
+ /**
+ * string protocolDesc = 12;
+ */
+ public Builder setProtocolDescBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ protocolDesc_ = value;
+ onChanged();
+ return this;
+ }
+ public final Builder setUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.setUnknownFieldsProto3(unknownFields);
+ }
+
+ public final Builder mergeUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.mergeUnknownFields(unknownFields);
+ }
+
+
+ // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.RequestHeader)
+ }
+
+ // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.RequestHeader)
+ private static final RequestHeader DEFAULT_INSTANCE;
+ static {
+ DEFAULT_INSTANCE = new RequestHeader();
+ }
+
+ public static RequestHeader getDefaultInstance() {
+ return DEFAULT_INSTANCE;
+ }
+
+ private static final com.google.protobuf.Parser
+ PARSER = new com.google.protobuf.AbstractParser() {
+ public RequestHeader parsePartialFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return new RequestHeader(input, extensionRegistry);
+ }
+ };
+
+ public static com.google.protobuf.Parser parser() {
+ return PARSER;
+ }
+
+ @Override
+ public com.google.protobuf.Parser getParserForType() {
+ return PARSER;
+ }
+
+ public RequestHeader getDefaultInstanceForType() {
+ return DEFAULT_INSTANCE;
+ }
+
+}
+
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java
new file mode 100644
index 0000000000..ab28df49f2
--- /dev/null
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/RequestHeaderOrBuilder.java
@@ -0,0 +1,129 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: eventmesh-client.proto
+
+package org.apache.eventmesh.common.protocol.grpc.protos;
+
+public interface RequestHeaderOrBuilder extends
+ // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.RequestHeader)
+ com.google.protobuf.MessageOrBuilder {
+
+ /**
+ * string env = 1;
+ */
+ String getEnv();
+ /**
+ * string env = 1;
+ */
+ com.google.protobuf.ByteString
+ getEnvBytes();
+
+ /**
+ * string region = 2;
+ */
+ String getRegion();
+ /**
+ * string region = 2;
+ */
+ com.google.protobuf.ByteString
+ getRegionBytes();
+
+ /**
+ * string idc = 3;
+ */
+ String getIdc();
+ /**
+ * string idc = 3;
+ */
+ com.google.protobuf.ByteString
+ getIdcBytes();
+
+ /**
+ * string ip = 4;
+ */
+ String getIp();
+ /**
+ * string ip = 4;
+ */
+ com.google.protobuf.ByteString
+ getIpBytes();
+
+ /**
+ * string pid = 5;
+ */
+ String getPid();
+ /**
+ * string pid = 5;
+ */
+ com.google.protobuf.ByteString
+ getPidBytes();
+
+ /**
+ * string sys = 6;
+ */
+ String getSys();
+ /**
+ * string sys = 6;
+ */
+ com.google.protobuf.ByteString
+ getSysBytes();
+
+ /**
+ * string username = 7;
+ */
+ String getUsername();
+ /**
+ * string username = 7;
+ */
+ com.google.protobuf.ByteString
+ getUsernameBytes();
+
+ /**
+ * string password = 8;
+ */
+ String getPassword();
+ /**
+ * string password = 8;
+ */
+ com.google.protobuf.ByteString
+ getPasswordBytes();
+
+ /**
+ * string language = 9;
+ */
+ String getLanguage();
+ /**
+ * string language = 9;
+ */
+ com.google.protobuf.ByteString
+ getLanguageBytes();
+
+ /**
+ * string protocolType = 10;
+ */
+ String getProtocolType();
+ /**
+ * string protocolType = 10;
+ */
+ com.google.protobuf.ByteString
+ getProtocolTypeBytes();
+
+ /**
+ * string protocolVersion = 11;
+ */
+ String getProtocolVersion();
+ /**
+ * string protocolVersion = 11;
+ */
+ com.google.protobuf.ByteString
+ getProtocolVersionBytes();
+
+ /**
+ * string protocolDesc = 12;
+ */
+ String getProtocolDesc();
+ /**
+ * string protocolDesc = 12;
+ */
+ com.google.protobuf.ByteString
+ getProtocolDescBytes();
+}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java
new file mode 100644
index 0000000000..008b0a1210
--- /dev/null
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Response.java
@@ -0,0 +1,897 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: eventmesh-client.proto
+
+package org.apache.eventmesh.common.protocol.grpc.protos;
+
+/**
+ * Protobuf type {@code eventmesh.common.protocol.grpc.Response}
+ */
+public final class Response extends
+ com.google.protobuf.GeneratedMessageV3 implements
+ // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.Response)
+ ResponseOrBuilder {
+private static final long serialVersionUID = 0L;
+ // Use Response.newBuilder() to construct.
+ private Response(com.google.protobuf.GeneratedMessageV3.Builder> builder) {
+ super(builder);
+ }
+ private Response() {
+ respCode_ = "";
+ respMsg_ = "";
+ respTime_ = "";
+ seqNum_ = "";
+ }
+
+ @Override
+ public final com.google.protobuf.UnknownFieldSet
+ getUnknownFields() {
+ return this.unknownFields;
+ }
+ private Response(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ this();
+ if (extensionRegistry == null) {
+ throw new NullPointerException();
+ }
+ int mutable_bitField0_ = 0;
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder();
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ default: {
+ if (!parseUnknownFieldProto3(
+ input, unknownFields, extensionRegistry, tag)) {
+ done = true;
+ }
+ break;
+ }
+ case 10: {
+ String s = input.readStringRequireUtf8();
+
+ respCode_ = s;
+ break;
+ }
+ case 18: {
+ String s = input.readStringRequireUtf8();
+
+ respMsg_ = s;
+ break;
+ }
+ case 26: {
+ String s = input.readStringRequireUtf8();
+
+ respTime_ = s;
+ break;
+ }
+ case 34: {
+ String s = input.readStringRequireUtf8();
+
+ seqNum_ = s;
+ break;
+ }
+ }
+ }
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(this);
+ } catch (java.io.IOException e) {
+ throw new com.google.protobuf.InvalidProtocolBufferException(
+ e).setUnfinishedMessage(this);
+ } finally {
+ this.unknownFields = unknownFields.build();
+ makeExtensionsImmutable();
+ }
+ }
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Response_descriptor;
+ }
+
+ protected FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Response_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ Response.class, Builder.class);
+ }
+
+ public static final int RESPCODE_FIELD_NUMBER = 1;
+ private volatile Object respCode_;
+ /**
+ * string respCode = 1;
+ */
+ public String getRespCode() {
+ Object ref = respCode_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ respCode_ = s;
+ return s;
+ }
+ }
+ /**
+ * string respCode = 1;
+ */
+ public com.google.protobuf.ByteString
+ getRespCodeBytes() {
+ Object ref = respCode_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ respCode_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int RESPMSG_FIELD_NUMBER = 2;
+ private volatile Object respMsg_;
+ /**
+ * string respMsg = 2;
+ */
+ public String getRespMsg() {
+ Object ref = respMsg_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ respMsg_ = s;
+ return s;
+ }
+ }
+ /**
+ * string respMsg = 2;
+ */
+ public com.google.protobuf.ByteString
+ getRespMsgBytes() {
+ Object ref = respMsg_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ respMsg_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int RESPTIME_FIELD_NUMBER = 3;
+ private volatile Object respTime_;
+ /**
+ * string respTime = 3;
+ */
+ public String getRespTime() {
+ Object ref = respTime_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ respTime_ = s;
+ return s;
+ }
+ }
+ /**
+ * string respTime = 3;
+ */
+ public com.google.protobuf.ByteString
+ getRespTimeBytes() {
+ Object ref = respTime_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ respTime_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int SEQNUM_FIELD_NUMBER = 4;
+ private volatile Object seqNum_;
+ /**
+ * string seqNum = 4;
+ */
+ public String getSeqNum() {
+ Object ref = seqNum_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ seqNum_ = s;
+ return s;
+ }
+ }
+ /**
+ * string seqNum = 4;
+ */
+ public com.google.protobuf.ByteString
+ getSeqNumBytes() {
+ Object ref = seqNum_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ seqNum_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized == 1) return true;
+ if (isInitialized == 0) return false;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ if (!getRespCodeBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 1, respCode_);
+ }
+ if (!getRespMsgBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 2, respMsg_);
+ }
+ if (!getRespTimeBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 3, respTime_);
+ }
+ if (!getSeqNumBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 4, seqNum_);
+ }
+ unknownFields.writeTo(output);
+ }
+
+ public int getSerializedSize() {
+ int size = memoizedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (!getRespCodeBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, respCode_);
+ }
+ if (!getRespMsgBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, respMsg_);
+ }
+ if (!getRespTimeBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, respTime_);
+ }
+ if (!getSeqNumBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, seqNum_);
+ }
+ size += unknownFields.getSerializedSize();
+ memoizedSize = size;
+ return size;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof Response)) {
+ return super.equals(obj);
+ }
+ Response other = (Response) obj;
+
+ boolean result = true;
+ result = result && getRespCode()
+ .equals(other.getRespCode());
+ result = result && getRespMsg()
+ .equals(other.getRespMsg());
+ result = result && getRespTime()
+ .equals(other.getRespTime());
+ result = result && getSeqNum()
+ .equals(other.getSeqNum());
+ result = result && unknownFields.equals(other.unknownFields);
+ return result;
+ }
+
+ @Override
+ public int hashCode() {
+ if (memoizedHashCode != 0) {
+ return memoizedHashCode;
+ }
+ int hash = 41;
+ hash = (19 * hash) + getDescriptor().hashCode();
+ hash = (37 * hash) + RESPCODE_FIELD_NUMBER;
+ hash = (53 * hash) + getRespCode().hashCode();
+ hash = (37 * hash) + RESPMSG_FIELD_NUMBER;
+ hash = (53 * hash) + getRespMsg().hashCode();
+ hash = (37 * hash) + RESPTIME_FIELD_NUMBER;
+ hash = (53 * hash) + getRespTime().hashCode();
+ hash = (37 * hash) + SEQNUM_FIELD_NUMBER;
+ hash = (53 * hash) + getSeqNum().hashCode();
+ hash = (29 * hash) + unknownFields.hashCode();
+ memoizedHashCode = hash;
+ return hash;
+ }
+
+ public static Response parseFrom(
+ java.nio.ByteBuffer data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static Response parseFrom(
+ java.nio.ByteBuffer data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static Response parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static Response parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static Response parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static Response parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static Response parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static Response parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static Response parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input);
+ }
+ public static Response parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static Response parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static Response parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder() {
+ return DEFAULT_INSTANCE.toBuilder();
+ }
+ public static Builder newBuilder(Response prototype) {
+ return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() {
+ return this == DEFAULT_INSTANCE
+ ? new Builder() : new Builder().mergeFrom(this);
+ }
+
+ @Override
+ protected Builder newBuilderForType(
+ BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ * Protobuf type {@code eventmesh.common.protocol.grpc.Response}
+ */
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessageV3.Builder implements
+ // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.Response)
+ ResponseOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Response_descriptor;
+ }
+
+ protected FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Response_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ Response.class, Builder.class);
+ }
+
+ // Construct using org.apache.eventmesh.common.protocol.grpc.protos.Response.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(
+ BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessageV3
+ .alwaysUseFieldBuilders) {
+ }
+ }
+ public Builder clear() {
+ super.clear();
+ respCode_ = "";
+
+ respMsg_ = "";
+
+ respTime_ = "";
+
+ seqNum_ = "";
+
+ return this;
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Response_descriptor;
+ }
+
+ public Response getDefaultInstanceForType() {
+ return Response.getDefaultInstance();
+ }
+
+ public Response build() {
+ Response result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ public Response buildPartial() {
+ Response result = new Response(this);
+ result.respCode_ = respCode_;
+ result.respMsg_ = respMsg_;
+ result.respTime_ = respTime_;
+ result.seqNum_ = seqNum_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder clone() {
+ return (Builder) super.clone();
+ }
+ public Builder setField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ Object value) {
+ return (Builder) super.setField(field, value);
+ }
+ public Builder clearField(
+ com.google.protobuf.Descriptors.FieldDescriptor field) {
+ return (Builder) super.clearField(field);
+ }
+ public Builder clearOneof(
+ com.google.protobuf.Descriptors.OneofDescriptor oneof) {
+ return (Builder) super.clearOneof(oneof);
+ }
+ public Builder setRepeatedField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ int index, Object value) {
+ return (Builder) super.setRepeatedField(field, index, value);
+ }
+ public Builder addRepeatedField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ Object value) {
+ return (Builder) super.addRepeatedField(field, value);
+ }
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof Response) {
+ return mergeFrom((Response)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(Response other) {
+ if (other == Response.getDefaultInstance()) return this;
+ if (!other.getRespCode().isEmpty()) {
+ respCode_ = other.respCode_;
+ onChanged();
+ }
+ if (!other.getRespMsg().isEmpty()) {
+ respMsg_ = other.respMsg_;
+ onChanged();
+ }
+ if (!other.getRespTime().isEmpty()) {
+ respTime_ = other.respTime_;
+ onChanged();
+ }
+ if (!other.getSeqNum().isEmpty()) {
+ seqNum_ = other.seqNum_;
+ onChanged();
+ }
+ this.mergeUnknownFields(other.unknownFields);
+ onChanged();
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ Response parsedMessage = null;
+ try {
+ parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ parsedMessage = (Response) e.getUnfinishedMessage();
+ throw e.unwrapIOException();
+ } finally {
+ if (parsedMessage != null) {
+ mergeFrom(parsedMessage);
+ }
+ }
+ return this;
+ }
+
+ private Object respCode_ = "";
+ /**
+ * string respCode = 1;
+ */
+ public String getRespCode() {
+ Object ref = respCode_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ respCode_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string respCode = 1;
+ */
+ public com.google.protobuf.ByteString
+ getRespCodeBytes() {
+ Object ref = respCode_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ respCode_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string respCode = 1;
+ */
+ public Builder setRespCode(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ respCode_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string respCode = 1;
+ */
+ public Builder clearRespCode() {
+
+ respCode_ = getDefaultInstance().getRespCode();
+ onChanged();
+ return this;
+ }
+ /**
+ * string respCode = 1;
+ */
+ public Builder setRespCodeBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ respCode_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object respMsg_ = "";
+ /**
+ * string respMsg = 2;
+ */
+ public String getRespMsg() {
+ Object ref = respMsg_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ respMsg_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string respMsg = 2;
+ */
+ public com.google.protobuf.ByteString
+ getRespMsgBytes() {
+ Object ref = respMsg_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ respMsg_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string respMsg = 2;
+ */
+ public Builder setRespMsg(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ respMsg_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string respMsg = 2;
+ */
+ public Builder clearRespMsg() {
+
+ respMsg_ = getDefaultInstance().getRespMsg();
+ onChanged();
+ return this;
+ }
+ /**
+ * string respMsg = 2;
+ */
+ public Builder setRespMsgBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ respMsg_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object respTime_ = "";
+ /**
+ * string respTime = 3;
+ */
+ public String getRespTime() {
+ Object ref = respTime_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ respTime_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string respTime = 3;
+ */
+ public com.google.protobuf.ByteString
+ getRespTimeBytes() {
+ Object ref = respTime_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ respTime_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string respTime = 3;
+ */
+ public Builder setRespTime(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ respTime_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string respTime = 3;
+ */
+ public Builder clearRespTime() {
+
+ respTime_ = getDefaultInstance().getRespTime();
+ onChanged();
+ return this;
+ }
+ /**
+ * string respTime = 3;
+ */
+ public Builder setRespTimeBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ respTime_ = value;
+ onChanged();
+ return this;
+ }
+
+ private Object seqNum_ = "";
+ /**
+ * string seqNum = 4;
+ */
+ public String getSeqNum() {
+ Object ref = seqNum_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ seqNum_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string seqNum = 4;
+ */
+ public com.google.protobuf.ByteString
+ getSeqNumBytes() {
+ Object ref = seqNum_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ seqNum_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string seqNum = 4;
+ */
+ public Builder setSeqNum(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ seqNum_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string seqNum = 4;
+ */
+ public Builder clearSeqNum() {
+
+ seqNum_ = getDefaultInstance().getSeqNum();
+ onChanged();
+ return this;
+ }
+ /**
+ * string seqNum = 4;
+ */
+ public Builder setSeqNumBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ seqNum_ = value;
+ onChanged();
+ return this;
+ }
+ public final Builder setUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.setUnknownFieldsProto3(unknownFields);
+ }
+
+ public final Builder mergeUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.mergeUnknownFields(unknownFields);
+ }
+
+
+ // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.Response)
+ }
+
+ // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.Response)
+ private static final Response DEFAULT_INSTANCE;
+ static {
+ DEFAULT_INSTANCE = new Response();
+ }
+
+ public static Response getDefaultInstance() {
+ return DEFAULT_INSTANCE;
+ }
+
+ private static final com.google.protobuf.Parser
+ PARSER = new com.google.protobuf.AbstractParser() {
+ public Response parsePartialFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return new Response(input, extensionRegistry);
+ }
+ };
+
+ public static com.google.protobuf.Parser parser() {
+ return PARSER;
+ }
+
+ @Override
+ public com.google.protobuf.Parser getParserForType() {
+ return PARSER;
+ }
+
+ public Response getDefaultInstanceForType() {
+ return DEFAULT_INSTANCE;
+ }
+
+}
+
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java
new file mode 100644
index 0000000000..701507deb9
--- /dev/null
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/ResponseOrBuilder.java
@@ -0,0 +1,49 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: eventmesh-client.proto
+
+package org.apache.eventmesh.common.protocol.grpc.protos;
+
+public interface ResponseOrBuilder extends
+ // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.Response)
+ com.google.protobuf.MessageOrBuilder {
+
+ /**
+ * string respCode = 1;
+ */
+ String getRespCode();
+ /**
+ * string respCode = 1;
+ */
+ com.google.protobuf.ByteString
+ getRespCodeBytes();
+
+ /**
+ * string respMsg = 2;
+ */
+ String getRespMsg();
+ /**
+ * string respMsg = 2;
+ */
+ com.google.protobuf.ByteString
+ getRespMsgBytes();
+
+ /**
+ * string respTime = 3;
+ */
+ String getRespTime();
+ /**
+ * string respTime = 3;
+ */
+ com.google.protobuf.ByteString
+ getRespTimeBytes();
+
+ /**
+ * string seqNum = 4;
+ */
+ String getSeqNum();
+ /**
+ * string seqNum = 4;
+ */
+ com.google.protobuf.ByteString
+ getSeqNumBytes();
+}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java
new file mode 100644
index 0000000000..76efe7dc6c
--- /dev/null
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/Subscription.java
@@ -0,0 +1,2077 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: eventmesh-client.proto
+
+package org.apache.eventmesh.common.protocol.grpc.protos;
+
+/**
+ * Protobuf type {@code eventmesh.common.protocol.grpc.Subscription}
+ */
+public final class Subscription extends
+ com.google.protobuf.GeneratedMessageV3 implements
+ // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.Subscription)
+ SubscriptionOrBuilder {
+private static final long serialVersionUID = 0L;
+ // Use Subscription.newBuilder() to construct.
+ private Subscription(com.google.protobuf.GeneratedMessageV3.Builder> builder) {
+ super(builder);
+ }
+ private Subscription() {
+ consumerGroup_ = "";
+ subscriptionItems_ = java.util.Collections.emptyList();
+ url_ = "";
+ }
+
+ @Override
+ public final com.google.protobuf.UnknownFieldSet
+ getUnknownFields() {
+ return this.unknownFields;
+ }
+ private Subscription(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ this();
+ if (extensionRegistry == null) {
+ throw new NullPointerException();
+ }
+ int mutable_bitField0_ = 0;
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder();
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ default: {
+ if (!parseUnknownFieldProto3(
+ input, unknownFields, extensionRegistry, tag)) {
+ done = true;
+ }
+ break;
+ }
+ case 10: {
+ RequestHeader.Builder subBuilder = null;
+ if (header_ != null) {
+ subBuilder = header_.toBuilder();
+ }
+ header_ = input.readMessage(RequestHeader.parser(), extensionRegistry);
+ if (subBuilder != null) {
+ subBuilder.mergeFrom(header_);
+ header_ = subBuilder.buildPartial();
+ }
+
+ break;
+ }
+ case 18: {
+ String s = input.readStringRequireUtf8();
+
+ consumerGroup_ = s;
+ break;
+ }
+ case 26: {
+ if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) {
+ subscriptionItems_ = new java.util.ArrayList();
+ mutable_bitField0_ |= 0x00000004;
+ }
+ subscriptionItems_.add(
+ input.readMessage(SubscriptionItem.parser(), extensionRegistry));
+ break;
+ }
+ case 34: {
+ String s = input.readStringRequireUtf8();
+
+ url_ = s;
+ break;
+ }
+ }
+ }
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(this);
+ } catch (java.io.IOException e) {
+ throw new com.google.protobuf.InvalidProtocolBufferException(
+ e).setUnfinishedMessage(this);
+ } finally {
+ if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) {
+ subscriptionItems_ = java.util.Collections.unmodifiableList(subscriptionItems_);
+ }
+ this.unknownFields = unknownFields.build();
+ makeExtensionsImmutable();
+ }
+ }
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor;
+ }
+
+ protected FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ Subscription.class, Builder.class);
+ }
+
+ public interface SubscriptionItemOrBuilder extends
+ // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem)
+ com.google.protobuf.MessageOrBuilder {
+
+ /**
+ * string topic = 1;
+ */
+ String getTopic();
+ /**
+ * string topic = 1;
+ */
+ com.google.protobuf.ByteString
+ getTopicBytes();
+
+ /**
+ * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2;
+ */
+ int getModeValue();
+ /**
+ * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2;
+ */
+ SubscriptionItem.SubscriptionMode getMode();
+
+ /**
+ * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3;
+ */
+ int getTypeValue();
+ /**
+ * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3;
+ */
+ SubscriptionItem.SubscriptionType getType();
+ }
+ /**
+ * Protobuf type {@code eventmesh.common.protocol.grpc.Subscription.SubscriptionItem}
+ */
+ public static final class SubscriptionItem extends
+ com.google.protobuf.GeneratedMessageV3 implements
+ // @@protoc_insertion_point(message_implements:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem)
+ SubscriptionItemOrBuilder {
+ private static final long serialVersionUID = 0L;
+ // Use SubscriptionItem.newBuilder() to construct.
+ private SubscriptionItem(com.google.protobuf.GeneratedMessageV3.Builder> builder) {
+ super(builder);
+ }
+ private SubscriptionItem() {
+ topic_ = "";
+ mode_ = 0;
+ type_ = 0;
+ }
+
+ @Override
+ public final com.google.protobuf.UnknownFieldSet
+ getUnknownFields() {
+ return this.unknownFields;
+ }
+ private SubscriptionItem(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ this();
+ if (extensionRegistry == null) {
+ throw new NullPointerException();
+ }
+ int mutable_bitField0_ = 0;
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder();
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ default: {
+ if (!parseUnknownFieldProto3(
+ input, unknownFields, extensionRegistry, tag)) {
+ done = true;
+ }
+ break;
+ }
+ case 10: {
+ String s = input.readStringRequireUtf8();
+
+ topic_ = s;
+ break;
+ }
+ case 16: {
+ int rawValue = input.readEnum();
+
+ mode_ = rawValue;
+ break;
+ }
+ case 24: {
+ int rawValue = input.readEnum();
+
+ type_ = rawValue;
+ break;
+ }
+ }
+ }
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(this);
+ } catch (java.io.IOException e) {
+ throw new com.google.protobuf.InvalidProtocolBufferException(
+ e).setUnfinishedMessage(this);
+ } finally {
+ this.unknownFields = unknownFields.build();
+ makeExtensionsImmutable();
+ }
+ }
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor;
+ }
+
+ protected FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ SubscriptionItem.class, Builder.class);
+ }
+
+ /**
+ * Protobuf enum {@code eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode}
+ */
+ public enum SubscriptionMode
+ implements com.google.protobuf.ProtocolMessageEnum {
+ /**
+ * CLUSTERING = 0;
+ */
+ CLUSTERING(0),
+ /**
+ * BROADCASTING = 1;
+ */
+ BROADCASTING(1),
+ UNRECOGNIZED(-1),
+ ;
+
+ /**
+ * CLUSTERING = 0;
+ */
+ public static final int CLUSTERING_VALUE = 0;
+ /**
+ * BROADCASTING = 1;
+ */
+ public static final int BROADCASTING_VALUE = 1;
+
+
+ public final int getNumber() {
+ if (this == UNRECOGNIZED) {
+ throw new IllegalArgumentException(
+ "Can't get the number of an unknown enum value.");
+ }
+ return value;
+ }
+
+ /**
+ * @deprecated Use {@link #forNumber(int)} instead.
+ */
+ @Deprecated
+ public static SubscriptionMode valueOf(int value) {
+ return forNumber(value);
+ }
+
+ public static SubscriptionMode forNumber(int value) {
+ switch (value) {
+ case 0: return CLUSTERING;
+ case 1: return BROADCASTING;
+ default: return null;
+ }
+ }
+
+ public static com.google.protobuf.Internal.EnumLiteMap
+ internalGetValueMap() {
+ return internalValueMap;
+ }
+ private static final com.google.protobuf.Internal.EnumLiteMap<
+ SubscriptionMode> internalValueMap =
+ new com.google.protobuf.Internal.EnumLiteMap() {
+ public SubscriptionMode findValueByNumber(int number) {
+ return SubscriptionMode.forNumber(number);
+ }
+ };
+
+ public final com.google.protobuf.Descriptors.EnumValueDescriptor
+ getValueDescriptor() {
+ return getDescriptor().getValues().get(ordinal());
+ }
+ public final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptorForType() {
+ return getDescriptor();
+ }
+ public static final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptor() {
+ return SubscriptionItem.getDescriptor().getEnumTypes().get(0);
+ }
+
+ private static final SubscriptionMode[] VALUES = values();
+
+ public static SubscriptionMode valueOf(
+ com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
+ if (desc.getType() != getDescriptor()) {
+ throw new IllegalArgumentException(
+ "EnumValueDescriptor is not for this type.");
+ }
+ if (desc.getIndex() == -1) {
+ return UNRECOGNIZED;
+ }
+ return VALUES[desc.getIndex()];
+ }
+
+ private final int value;
+
+ private SubscriptionMode(int value) {
+ this.value = value;
+ }
+
+ // @@protoc_insertion_point(enum_scope:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode)
+ }
+
+ /**
+ * Protobuf enum {@code eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType}
+ */
+ public enum SubscriptionType
+ implements com.google.protobuf.ProtocolMessageEnum {
+ /**
+ * ASYNC = 0;
+ */
+ ASYNC(0),
+ /**
+ * SYNC = 1;
+ */
+ SYNC(1),
+ UNRECOGNIZED(-1),
+ ;
+
+ /**
+ * ASYNC = 0;
+ */
+ public static final int ASYNC_VALUE = 0;
+ /**
+ * SYNC = 1;
+ */
+ public static final int SYNC_VALUE = 1;
+
+
+ public final int getNumber() {
+ if (this == UNRECOGNIZED) {
+ throw new IllegalArgumentException(
+ "Can't get the number of an unknown enum value.");
+ }
+ return value;
+ }
+
+ /**
+ * @deprecated Use {@link #forNumber(int)} instead.
+ */
+ @Deprecated
+ public static SubscriptionType valueOf(int value) {
+ return forNumber(value);
+ }
+
+ public static SubscriptionType forNumber(int value) {
+ switch (value) {
+ case 0: return ASYNC;
+ case 1: return SYNC;
+ default: return null;
+ }
+ }
+
+ public static com.google.protobuf.Internal.EnumLiteMap
+ internalGetValueMap() {
+ return internalValueMap;
+ }
+ private static final com.google.protobuf.Internal.EnumLiteMap<
+ SubscriptionType> internalValueMap =
+ new com.google.protobuf.Internal.EnumLiteMap() {
+ public SubscriptionType findValueByNumber(int number) {
+ return SubscriptionType.forNumber(number);
+ }
+ };
+
+ public final com.google.protobuf.Descriptors.EnumValueDescriptor
+ getValueDescriptor() {
+ return getDescriptor().getValues().get(ordinal());
+ }
+ public final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptorForType() {
+ return getDescriptor();
+ }
+ public static final com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptor() {
+ return SubscriptionItem.getDescriptor().getEnumTypes().get(1);
+ }
+
+ private static final SubscriptionType[] VALUES = values();
+
+ public static SubscriptionType valueOf(
+ com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
+ if (desc.getType() != getDescriptor()) {
+ throw new IllegalArgumentException(
+ "EnumValueDescriptor is not for this type.");
+ }
+ if (desc.getIndex() == -1) {
+ return UNRECOGNIZED;
+ }
+ return VALUES[desc.getIndex()];
+ }
+
+ private final int value;
+
+ private SubscriptionType(int value) {
+ this.value = value;
+ }
+
+ // @@protoc_insertion_point(enum_scope:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType)
+ }
+
+ public static final int TOPIC_FIELD_NUMBER = 1;
+ private volatile Object topic_;
+ /**
+ * string topic = 1;
+ */
+ public String getTopic() {
+ Object ref = topic_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ topic_ = s;
+ return s;
+ }
+ }
+ /**
+ * string topic = 1;
+ */
+ public com.google.protobuf.ByteString
+ getTopicBytes() {
+ Object ref = topic_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ topic_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int MODE_FIELD_NUMBER = 2;
+ private int mode_;
+ /**
+ * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2;
+ */
+ public int getModeValue() {
+ return mode_;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2;
+ */
+ public SubscriptionMode getMode() {
+ SubscriptionMode result = SubscriptionMode.valueOf(mode_);
+ return result == null ? SubscriptionMode.UNRECOGNIZED : result;
+ }
+
+ public static final int TYPE_FIELD_NUMBER = 3;
+ private int type_;
+ /**
+ * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3;
+ */
+ public int getTypeValue() {
+ return type_;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3;
+ */
+ public SubscriptionType getType() {
+ SubscriptionType result = SubscriptionType.valueOf(type_);
+ return result == null ? SubscriptionType.UNRECOGNIZED : result;
+ }
+
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized == 1) return true;
+ if (isInitialized == 0) return false;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ if (!getTopicBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 1, topic_);
+ }
+ if (mode_ != SubscriptionMode.CLUSTERING.getNumber()) {
+ output.writeEnum(2, mode_);
+ }
+ if (type_ != SubscriptionType.ASYNC.getNumber()) {
+ output.writeEnum(3, type_);
+ }
+ unknownFields.writeTo(output);
+ }
+
+ public int getSerializedSize() {
+ int size = memoizedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (!getTopicBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, topic_);
+ }
+ if (mode_ != SubscriptionMode.CLUSTERING.getNumber()) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeEnumSize(2, mode_);
+ }
+ if (type_ != SubscriptionType.ASYNC.getNumber()) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeEnumSize(3, type_);
+ }
+ size += unknownFields.getSerializedSize();
+ memoizedSize = size;
+ return size;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof SubscriptionItem)) {
+ return super.equals(obj);
+ }
+ SubscriptionItem other = (SubscriptionItem) obj;
+
+ boolean result = true;
+ result = result && getTopic()
+ .equals(other.getTopic());
+ result = result && mode_ == other.mode_;
+ result = result && type_ == other.type_;
+ result = result && unknownFields.equals(other.unknownFields);
+ return result;
+ }
+
+ @Override
+ public int hashCode() {
+ if (memoizedHashCode != 0) {
+ return memoizedHashCode;
+ }
+ int hash = 41;
+ hash = (19 * hash) + getDescriptor().hashCode();
+ hash = (37 * hash) + TOPIC_FIELD_NUMBER;
+ hash = (53 * hash) + getTopic().hashCode();
+ hash = (37 * hash) + MODE_FIELD_NUMBER;
+ hash = (53 * hash) + mode_;
+ hash = (37 * hash) + TYPE_FIELD_NUMBER;
+ hash = (53 * hash) + type_;
+ hash = (29 * hash) + unknownFields.hashCode();
+ memoizedHashCode = hash;
+ return hash;
+ }
+
+ public static SubscriptionItem parseFrom(
+ java.nio.ByteBuffer data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static SubscriptionItem parseFrom(
+ java.nio.ByteBuffer data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static SubscriptionItem parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static SubscriptionItem parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static SubscriptionItem parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static SubscriptionItem parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static SubscriptionItem parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static SubscriptionItem parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static SubscriptionItem parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input);
+ }
+ public static SubscriptionItem parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static SubscriptionItem parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static SubscriptionItem parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder() {
+ return DEFAULT_INSTANCE.toBuilder();
+ }
+ public static Builder newBuilder(SubscriptionItem prototype) {
+ return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() {
+ return this == DEFAULT_INSTANCE
+ ? new Builder() : new Builder().mergeFrom(this);
+ }
+
+ @Override
+ protected Builder newBuilderForType(
+ BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ * Protobuf type {@code eventmesh.common.protocol.grpc.Subscription.SubscriptionItem}
+ */
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessageV3.Builder implements
+ // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem)
+ SubscriptionItemOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor;
+ }
+
+ protected FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ SubscriptionItem.class, Builder.class);
+ }
+
+ // Construct using org.apache.eventmesh.common.protocol.grpc.protos.Subscription.SubscriptionItem.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(
+ BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessageV3
+ .alwaysUseFieldBuilders) {
+ }
+ }
+ public Builder clear() {
+ super.clear();
+ topic_ = "";
+
+ mode_ = 0;
+
+ type_ = 0;
+
+ return this;
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_SubscriptionItem_descriptor;
+ }
+
+ public SubscriptionItem getDefaultInstanceForType() {
+ return SubscriptionItem.getDefaultInstance();
+ }
+
+ public SubscriptionItem build() {
+ SubscriptionItem result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ public SubscriptionItem buildPartial() {
+ SubscriptionItem result = new SubscriptionItem(this);
+ result.topic_ = topic_;
+ result.mode_ = mode_;
+ result.type_ = type_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder clone() {
+ return (Builder) super.clone();
+ }
+ public Builder setField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ Object value) {
+ return (Builder) super.setField(field, value);
+ }
+ public Builder clearField(
+ com.google.protobuf.Descriptors.FieldDescriptor field) {
+ return (Builder) super.clearField(field);
+ }
+ public Builder clearOneof(
+ com.google.protobuf.Descriptors.OneofDescriptor oneof) {
+ return (Builder) super.clearOneof(oneof);
+ }
+ public Builder setRepeatedField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ int index, Object value) {
+ return (Builder) super.setRepeatedField(field, index, value);
+ }
+ public Builder addRepeatedField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ Object value) {
+ return (Builder) super.addRepeatedField(field, value);
+ }
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof SubscriptionItem) {
+ return mergeFrom((SubscriptionItem)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(SubscriptionItem other) {
+ if (other == SubscriptionItem.getDefaultInstance()) return this;
+ if (!other.getTopic().isEmpty()) {
+ topic_ = other.topic_;
+ onChanged();
+ }
+ if (other.mode_ != 0) {
+ setModeValue(other.getModeValue());
+ }
+ if (other.type_ != 0) {
+ setTypeValue(other.getTypeValue());
+ }
+ this.mergeUnknownFields(other.unknownFields);
+ onChanged();
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ SubscriptionItem parsedMessage = null;
+ try {
+ parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ parsedMessage = (SubscriptionItem) e.getUnfinishedMessage();
+ throw e.unwrapIOException();
+ } finally {
+ if (parsedMessage != null) {
+ mergeFrom(parsedMessage);
+ }
+ }
+ return this;
+ }
+
+ private Object topic_ = "";
+ /**
+ * string topic = 1;
+ */
+ public String getTopic() {
+ Object ref = topic_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ topic_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string topic = 1;
+ */
+ public com.google.protobuf.ByteString
+ getTopicBytes() {
+ Object ref = topic_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ topic_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string topic = 1;
+ */
+ public Builder setTopic(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ topic_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string topic = 1;
+ */
+ public Builder clearTopic() {
+
+ topic_ = getDefaultInstance().getTopic();
+ onChanged();
+ return this;
+ }
+ /**
+ * string topic = 1;
+ */
+ public Builder setTopicBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ topic_ = value;
+ onChanged();
+ return this;
+ }
+
+ private int mode_ = 0;
+ /**
+ * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2;
+ */
+ public int getModeValue() {
+ return mode_;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2;
+ */
+ public Builder setModeValue(int value) {
+ mode_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2;
+ */
+ public SubscriptionMode getMode() {
+ SubscriptionMode result = SubscriptionMode.valueOf(mode_);
+ return result == null ? SubscriptionMode.UNRECOGNIZED : result;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2;
+ */
+ public Builder setMode(SubscriptionMode value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ mode_ = value.getNumber();
+ onChanged();
+ return this;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionMode mode = 2;
+ */
+ public Builder clearMode() {
+
+ mode_ = 0;
+ onChanged();
+ return this;
+ }
+
+ private int type_ = 0;
+ /**
+ * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3;
+ */
+ public int getTypeValue() {
+ return type_;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3;
+ */
+ public Builder setTypeValue(int value) {
+ type_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3;
+ */
+ public SubscriptionType getType() {
+ SubscriptionType result = SubscriptionType.valueOf(type_);
+ return result == null ? SubscriptionType.UNRECOGNIZED : result;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3;
+ */
+ public Builder setType(SubscriptionType value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ type_ = value.getNumber();
+ onChanged();
+ return this;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem.SubscriptionType type = 3;
+ */
+ public Builder clearType() {
+
+ type_ = 0;
+ onChanged();
+ return this;
+ }
+ public final Builder setUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.setUnknownFieldsProto3(unknownFields);
+ }
+
+ public final Builder mergeUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.mergeUnknownFields(unknownFields);
+ }
+
+
+ // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem)
+ }
+
+ // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.Subscription.SubscriptionItem)
+ private static final SubscriptionItem DEFAULT_INSTANCE;
+ static {
+ DEFAULT_INSTANCE = new SubscriptionItem();
+ }
+
+ public static SubscriptionItem getDefaultInstance() {
+ return DEFAULT_INSTANCE;
+ }
+
+ private static final com.google.protobuf.Parser
+ PARSER = new com.google.protobuf.AbstractParser() {
+ public SubscriptionItem parsePartialFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return new SubscriptionItem(input, extensionRegistry);
+ }
+ };
+
+ public static com.google.protobuf.Parser parser() {
+ return PARSER;
+ }
+
+ @Override
+ public com.google.protobuf.Parser getParserForType() {
+ return PARSER;
+ }
+
+ public SubscriptionItem getDefaultInstanceForType() {
+ return DEFAULT_INSTANCE;
+ }
+
+ }
+
+ private int bitField0_;
+ public static final int HEADER_FIELD_NUMBER = 1;
+ private RequestHeader header_;
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public boolean hasHeader() {
+ return header_ != null;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public RequestHeader getHeader() {
+ return header_ == null ? RequestHeader.getDefaultInstance() : header_;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public RequestHeaderOrBuilder getHeaderOrBuilder() {
+ return getHeader();
+ }
+
+ public static final int CONSUMERGROUP_FIELD_NUMBER = 2;
+ private volatile Object consumerGroup_;
+ /**
+ * string consumerGroup = 2;
+ */
+ public String getConsumerGroup() {
+ Object ref = consumerGroup_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ consumerGroup_ = s;
+ return s;
+ }
+ }
+ /**
+ * string consumerGroup = 2;
+ */
+ public com.google.protobuf.ByteString
+ getConsumerGroupBytes() {
+ Object ref = consumerGroup_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ consumerGroup_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int SUBSCRIPTIONITEMS_FIELD_NUMBER = 3;
+ private java.util.List subscriptionItems_;
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public java.util.List getSubscriptionItemsList() {
+ return subscriptionItems_;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public java.util.List extends SubscriptionItemOrBuilder>
+ getSubscriptionItemsOrBuilderList() {
+ return subscriptionItems_;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public int getSubscriptionItemsCount() {
+ return subscriptionItems_.size();
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public SubscriptionItem getSubscriptionItems(int index) {
+ return subscriptionItems_.get(index);
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public SubscriptionItemOrBuilder getSubscriptionItemsOrBuilder(
+ int index) {
+ return subscriptionItems_.get(index);
+ }
+
+ public static final int URL_FIELD_NUMBER = 4;
+ private volatile Object url_;
+ /**
+ * string url = 4;
+ */
+ public String getUrl() {
+ Object ref = url_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ url_ = s;
+ return s;
+ }
+ }
+ /**
+ * string url = 4;
+ */
+ public com.google.protobuf.ByteString
+ getUrlBytes() {
+ Object ref = url_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ url_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized == 1) return true;
+ if (isInitialized == 0) return false;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ if (header_ != null) {
+ output.writeMessage(1, getHeader());
+ }
+ if (!getConsumerGroupBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 2, consumerGroup_);
+ }
+ for (int i = 0; i < subscriptionItems_.size(); i++) {
+ output.writeMessage(3, subscriptionItems_.get(i));
+ }
+ if (!getUrlBytes().isEmpty()) {
+ com.google.protobuf.GeneratedMessageV3.writeString(output, 4, url_);
+ }
+ unknownFields.writeTo(output);
+ }
+
+ public int getSerializedSize() {
+ int size = memoizedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (header_ != null) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeMessageSize(1, getHeader());
+ }
+ if (!getConsumerGroupBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, consumerGroup_);
+ }
+ for (int i = 0; i < subscriptionItems_.size(); i++) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeMessageSize(3, subscriptionItems_.get(i));
+ }
+ if (!getUrlBytes().isEmpty()) {
+ size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, url_);
+ }
+ size += unknownFields.getSerializedSize();
+ memoizedSize = size;
+ return size;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof Subscription)) {
+ return super.equals(obj);
+ }
+ Subscription other = (Subscription) obj;
+
+ boolean result = true;
+ result = result && (hasHeader() == other.hasHeader());
+ if (hasHeader()) {
+ result = result && getHeader()
+ .equals(other.getHeader());
+ }
+ result = result && getConsumerGroup()
+ .equals(other.getConsumerGroup());
+ result = result && getSubscriptionItemsList()
+ .equals(other.getSubscriptionItemsList());
+ result = result && getUrl()
+ .equals(other.getUrl());
+ result = result && unknownFields.equals(other.unknownFields);
+ return result;
+ }
+
+ @Override
+ public int hashCode() {
+ if (memoizedHashCode != 0) {
+ return memoizedHashCode;
+ }
+ int hash = 41;
+ hash = (19 * hash) + getDescriptor().hashCode();
+ if (hasHeader()) {
+ hash = (37 * hash) + HEADER_FIELD_NUMBER;
+ hash = (53 * hash) + getHeader().hashCode();
+ }
+ hash = (37 * hash) + CONSUMERGROUP_FIELD_NUMBER;
+ hash = (53 * hash) + getConsumerGroup().hashCode();
+ if (getSubscriptionItemsCount() > 0) {
+ hash = (37 * hash) + SUBSCRIPTIONITEMS_FIELD_NUMBER;
+ hash = (53 * hash) + getSubscriptionItemsList().hashCode();
+ }
+ hash = (37 * hash) + URL_FIELD_NUMBER;
+ hash = (53 * hash) + getUrl().hashCode();
+ hash = (29 * hash) + unknownFields.hashCode();
+ memoizedHashCode = hash;
+ return hash;
+ }
+
+ public static Subscription parseFrom(
+ java.nio.ByteBuffer data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static Subscription parseFrom(
+ java.nio.ByteBuffer data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static Subscription parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static Subscription parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static Subscription parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static Subscription parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static Subscription parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static Subscription parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static Subscription parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input);
+ }
+ public static Subscription parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static Subscription parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static Subscription parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder() {
+ return DEFAULT_INSTANCE.toBuilder();
+ }
+ public static Builder newBuilder(Subscription prototype) {
+ return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() {
+ return this == DEFAULT_INSTANCE
+ ? new Builder() : new Builder().mergeFrom(this);
+ }
+
+ @Override
+ protected Builder newBuilderForType(
+ BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ * Protobuf type {@code eventmesh.common.protocol.grpc.Subscription}
+ */
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessageV3.Builder implements
+ // @@protoc_insertion_point(builder_implements:eventmesh.common.protocol.grpc.Subscription)
+ SubscriptionOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor;
+ }
+
+ protected FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ Subscription.class, Builder.class);
+ }
+
+ // Construct using org.apache.eventmesh.common.protocol.grpc.protos.Subscription.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(
+ BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessageV3
+ .alwaysUseFieldBuilders) {
+ getSubscriptionItemsFieldBuilder();
+ }
+ }
+ public Builder clear() {
+ super.clear();
+ if (headerBuilder_ == null) {
+ header_ = null;
+ } else {
+ header_ = null;
+ headerBuilder_ = null;
+ }
+ consumerGroup_ = "";
+
+ if (subscriptionItemsBuilder_ == null) {
+ subscriptionItems_ = java.util.Collections.emptyList();
+ bitField0_ = (bitField0_ & ~0x00000004);
+ } else {
+ subscriptionItemsBuilder_.clear();
+ }
+ url_ = "";
+
+ return this;
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return EventmeshGrpc.internal_static_eventmesh_common_protocol_grpc_Subscription_descriptor;
+ }
+
+ public Subscription getDefaultInstanceForType() {
+ return Subscription.getDefaultInstance();
+ }
+
+ public Subscription build() {
+ Subscription result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ public Subscription buildPartial() {
+ Subscription result = new Subscription(this);
+ int from_bitField0_ = bitField0_;
+ int to_bitField0_ = 0;
+ if (headerBuilder_ == null) {
+ result.header_ = header_;
+ } else {
+ result.header_ = headerBuilder_.build();
+ }
+ result.consumerGroup_ = consumerGroup_;
+ if (subscriptionItemsBuilder_ == null) {
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ subscriptionItems_ = java.util.Collections.unmodifiableList(subscriptionItems_);
+ bitField0_ = (bitField0_ & ~0x00000004);
+ }
+ result.subscriptionItems_ = subscriptionItems_;
+ } else {
+ result.subscriptionItems_ = subscriptionItemsBuilder_.build();
+ }
+ result.url_ = url_;
+ result.bitField0_ = to_bitField0_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder clone() {
+ return (Builder) super.clone();
+ }
+ public Builder setField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ Object value) {
+ return (Builder) super.setField(field, value);
+ }
+ public Builder clearField(
+ com.google.protobuf.Descriptors.FieldDescriptor field) {
+ return (Builder) super.clearField(field);
+ }
+ public Builder clearOneof(
+ com.google.protobuf.Descriptors.OneofDescriptor oneof) {
+ return (Builder) super.clearOneof(oneof);
+ }
+ public Builder setRepeatedField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ int index, Object value) {
+ return (Builder) super.setRepeatedField(field, index, value);
+ }
+ public Builder addRepeatedField(
+ com.google.protobuf.Descriptors.FieldDescriptor field,
+ Object value) {
+ return (Builder) super.addRepeatedField(field, value);
+ }
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof Subscription) {
+ return mergeFrom((Subscription)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(Subscription other) {
+ if (other == Subscription.getDefaultInstance()) return this;
+ if (other.hasHeader()) {
+ mergeHeader(other.getHeader());
+ }
+ if (!other.getConsumerGroup().isEmpty()) {
+ consumerGroup_ = other.consumerGroup_;
+ onChanged();
+ }
+ if (subscriptionItemsBuilder_ == null) {
+ if (!other.subscriptionItems_.isEmpty()) {
+ if (subscriptionItems_.isEmpty()) {
+ subscriptionItems_ = other.subscriptionItems_;
+ bitField0_ = (bitField0_ & ~0x00000004);
+ } else {
+ ensureSubscriptionItemsIsMutable();
+ subscriptionItems_.addAll(other.subscriptionItems_);
+ }
+ onChanged();
+ }
+ } else {
+ if (!other.subscriptionItems_.isEmpty()) {
+ if (subscriptionItemsBuilder_.isEmpty()) {
+ subscriptionItemsBuilder_.dispose();
+ subscriptionItemsBuilder_ = null;
+ subscriptionItems_ = other.subscriptionItems_;
+ bitField0_ = (bitField0_ & ~0x00000004);
+ subscriptionItemsBuilder_ =
+ com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+ getSubscriptionItemsFieldBuilder() : null;
+ } else {
+ subscriptionItemsBuilder_.addAllMessages(other.subscriptionItems_);
+ }
+ }
+ }
+ if (!other.getUrl().isEmpty()) {
+ url_ = other.url_;
+ onChanged();
+ }
+ this.mergeUnknownFields(other.unknownFields);
+ onChanged();
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ Subscription parsedMessage = null;
+ try {
+ parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ parsedMessage = (Subscription) e.getUnfinishedMessage();
+ throw e.unwrapIOException();
+ } finally {
+ if (parsedMessage != null) {
+ mergeFrom(parsedMessage);
+ }
+ }
+ return this;
+ }
+ private int bitField0_;
+
+ private RequestHeader header_ = null;
+ private com.google.protobuf.SingleFieldBuilderV3<
+ RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder> headerBuilder_;
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public boolean hasHeader() {
+ return headerBuilder_ != null || header_ != null;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public RequestHeader getHeader() {
+ if (headerBuilder_ == null) {
+ return header_ == null ? RequestHeader.getDefaultInstance() : header_;
+ } else {
+ return headerBuilder_.getMessage();
+ }
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public Builder setHeader(RequestHeader value) {
+ if (headerBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ header_ = value;
+ onChanged();
+ } else {
+ headerBuilder_.setMessage(value);
+ }
+
+ return this;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public Builder setHeader(
+ RequestHeader.Builder builderForValue) {
+ if (headerBuilder_ == null) {
+ header_ = builderForValue.build();
+ onChanged();
+ } else {
+ headerBuilder_.setMessage(builderForValue.build());
+ }
+
+ return this;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public Builder mergeHeader(RequestHeader value) {
+ if (headerBuilder_ == null) {
+ if (header_ != null) {
+ header_ =
+ RequestHeader.newBuilder(header_).mergeFrom(value).buildPartial();
+ } else {
+ header_ = value;
+ }
+ onChanged();
+ } else {
+ headerBuilder_.mergeFrom(value);
+ }
+
+ return this;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public Builder clearHeader() {
+ if (headerBuilder_ == null) {
+ header_ = null;
+ onChanged();
+ } else {
+ header_ = null;
+ headerBuilder_ = null;
+ }
+
+ return this;
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public RequestHeader.Builder getHeaderBuilder() {
+
+ onChanged();
+ return getHeaderFieldBuilder().getBuilder();
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ public RequestHeaderOrBuilder getHeaderOrBuilder() {
+ if (headerBuilder_ != null) {
+ return headerBuilder_.getMessageOrBuilder();
+ } else {
+ return header_ == null ?
+ RequestHeader.getDefaultInstance() : header_;
+ }
+ }
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ private com.google.protobuf.SingleFieldBuilderV3<
+ RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>
+ getHeaderFieldBuilder() {
+ if (headerBuilder_ == null) {
+ headerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
+ RequestHeader, RequestHeader.Builder, RequestHeaderOrBuilder>(
+ getHeader(),
+ getParentForChildren(),
+ isClean());
+ header_ = null;
+ }
+ return headerBuilder_;
+ }
+
+ private Object consumerGroup_ = "";
+ /**
+ * string consumerGroup = 2;
+ */
+ public String getConsumerGroup() {
+ Object ref = consumerGroup_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ consumerGroup_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string consumerGroup = 2;
+ */
+ public com.google.protobuf.ByteString
+ getConsumerGroupBytes() {
+ Object ref = consumerGroup_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ consumerGroup_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string consumerGroup = 2;
+ */
+ public Builder setConsumerGroup(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ consumerGroup_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string consumerGroup = 2;
+ */
+ public Builder clearConsumerGroup() {
+
+ consumerGroup_ = getDefaultInstance().getConsumerGroup();
+ onChanged();
+ return this;
+ }
+ /**
+ * string consumerGroup = 2;
+ */
+ public Builder setConsumerGroupBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ consumerGroup_ = value;
+ onChanged();
+ return this;
+ }
+
+ private java.util.List subscriptionItems_ =
+ java.util.Collections.emptyList();
+ private void ensureSubscriptionItemsIsMutable() {
+ if (!((bitField0_ & 0x00000004) == 0x00000004)) {
+ subscriptionItems_ = new java.util.ArrayList(subscriptionItems_);
+ bitField0_ |= 0x00000004;
+ }
+ }
+
+ private com.google.protobuf.RepeatedFieldBuilderV3<
+ SubscriptionItem, SubscriptionItem.Builder, SubscriptionItemOrBuilder> subscriptionItemsBuilder_;
+
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public java.util.List getSubscriptionItemsList() {
+ if (subscriptionItemsBuilder_ == null) {
+ return java.util.Collections.unmodifiableList(subscriptionItems_);
+ } else {
+ return subscriptionItemsBuilder_.getMessageList();
+ }
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public int getSubscriptionItemsCount() {
+ if (subscriptionItemsBuilder_ == null) {
+ return subscriptionItems_.size();
+ } else {
+ return subscriptionItemsBuilder_.getCount();
+ }
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public SubscriptionItem getSubscriptionItems(int index) {
+ if (subscriptionItemsBuilder_ == null) {
+ return subscriptionItems_.get(index);
+ } else {
+ return subscriptionItemsBuilder_.getMessage(index);
+ }
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public Builder setSubscriptionItems(
+ int index, SubscriptionItem value) {
+ if (subscriptionItemsBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureSubscriptionItemsIsMutable();
+ subscriptionItems_.set(index, value);
+ onChanged();
+ } else {
+ subscriptionItemsBuilder_.setMessage(index, value);
+ }
+ return this;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public Builder setSubscriptionItems(
+ int index, SubscriptionItem.Builder builderForValue) {
+ if (subscriptionItemsBuilder_ == null) {
+ ensureSubscriptionItemsIsMutable();
+ subscriptionItems_.set(index, builderForValue.build());
+ onChanged();
+ } else {
+ subscriptionItemsBuilder_.setMessage(index, builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public Builder addSubscriptionItems(SubscriptionItem value) {
+ if (subscriptionItemsBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureSubscriptionItemsIsMutable();
+ subscriptionItems_.add(value);
+ onChanged();
+ } else {
+ subscriptionItemsBuilder_.addMessage(value);
+ }
+ return this;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public Builder addSubscriptionItems(
+ int index, SubscriptionItem value) {
+ if (subscriptionItemsBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureSubscriptionItemsIsMutable();
+ subscriptionItems_.add(index, value);
+ onChanged();
+ } else {
+ subscriptionItemsBuilder_.addMessage(index, value);
+ }
+ return this;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public Builder addSubscriptionItems(
+ SubscriptionItem.Builder builderForValue) {
+ if (subscriptionItemsBuilder_ == null) {
+ ensureSubscriptionItemsIsMutable();
+ subscriptionItems_.add(builderForValue.build());
+ onChanged();
+ } else {
+ subscriptionItemsBuilder_.addMessage(builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public Builder addSubscriptionItems(
+ int index, SubscriptionItem.Builder builderForValue) {
+ if (subscriptionItemsBuilder_ == null) {
+ ensureSubscriptionItemsIsMutable();
+ subscriptionItems_.add(index, builderForValue.build());
+ onChanged();
+ } else {
+ subscriptionItemsBuilder_.addMessage(index, builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public Builder addAllSubscriptionItems(
+ Iterable extends SubscriptionItem> values) {
+ if (subscriptionItemsBuilder_ == null) {
+ ensureSubscriptionItemsIsMutable();
+ com.google.protobuf.AbstractMessageLite.Builder.addAll(
+ values, subscriptionItems_);
+ onChanged();
+ } else {
+ subscriptionItemsBuilder_.addAllMessages(values);
+ }
+ return this;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public Builder clearSubscriptionItems() {
+ if (subscriptionItemsBuilder_ == null) {
+ subscriptionItems_ = java.util.Collections.emptyList();
+ bitField0_ = (bitField0_ & ~0x00000004);
+ onChanged();
+ } else {
+ subscriptionItemsBuilder_.clear();
+ }
+ return this;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public Builder removeSubscriptionItems(int index) {
+ if (subscriptionItemsBuilder_ == null) {
+ ensureSubscriptionItemsIsMutable();
+ subscriptionItems_.remove(index);
+ onChanged();
+ } else {
+ subscriptionItemsBuilder_.remove(index);
+ }
+ return this;
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public SubscriptionItem.Builder getSubscriptionItemsBuilder(
+ int index) {
+ return getSubscriptionItemsFieldBuilder().getBuilder(index);
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public SubscriptionItemOrBuilder getSubscriptionItemsOrBuilder(
+ int index) {
+ if (subscriptionItemsBuilder_ == null) {
+ return subscriptionItems_.get(index); } else {
+ return subscriptionItemsBuilder_.getMessageOrBuilder(index);
+ }
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public java.util.List extends SubscriptionItemOrBuilder>
+ getSubscriptionItemsOrBuilderList() {
+ if (subscriptionItemsBuilder_ != null) {
+ return subscriptionItemsBuilder_.getMessageOrBuilderList();
+ } else {
+ return java.util.Collections.unmodifiableList(subscriptionItems_);
+ }
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public SubscriptionItem.Builder addSubscriptionItemsBuilder() {
+ return getSubscriptionItemsFieldBuilder().addBuilder(
+ SubscriptionItem.getDefaultInstance());
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public SubscriptionItem.Builder addSubscriptionItemsBuilder(
+ int index) {
+ return getSubscriptionItemsFieldBuilder().addBuilder(
+ index, SubscriptionItem.getDefaultInstance());
+ }
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ public java.util.List
+ getSubscriptionItemsBuilderList() {
+ return getSubscriptionItemsFieldBuilder().getBuilderList();
+ }
+ private com.google.protobuf.RepeatedFieldBuilderV3<
+ SubscriptionItem, SubscriptionItem.Builder, SubscriptionItemOrBuilder>
+ getSubscriptionItemsFieldBuilder() {
+ if (subscriptionItemsBuilder_ == null) {
+ subscriptionItemsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
+ SubscriptionItem, SubscriptionItem.Builder, SubscriptionItemOrBuilder>(
+ subscriptionItems_,
+ ((bitField0_ & 0x00000004) == 0x00000004),
+ getParentForChildren(),
+ isClean());
+ subscriptionItems_ = null;
+ }
+ return subscriptionItemsBuilder_;
+ }
+
+ private Object url_ = "";
+ /**
+ * string url = 4;
+ */
+ public String getUrl() {
+ Object ref = url_;
+ if (!(ref instanceof String)) {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ url_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ /**
+ * string url = 4;
+ */
+ public com.google.protobuf.ByteString
+ getUrlBytes() {
+ Object ref = url_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8(
+ (String) ref);
+ url_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * string url = 4;
+ */
+ public Builder setUrl(
+ String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+
+ url_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * string url = 4;
+ */
+ public Builder clearUrl() {
+
+ url_ = getDefaultInstance().getUrl();
+ onChanged();
+ return this;
+ }
+ /**
+ * string url = 4;
+ */
+ public Builder setUrlBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ checkByteStringIsUtf8(value);
+
+ url_ = value;
+ onChanged();
+ return this;
+ }
+ public final Builder setUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.setUnknownFieldsProto3(unknownFields);
+ }
+
+ public final Builder mergeUnknownFields(
+ final com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.mergeUnknownFields(unknownFields);
+ }
+
+
+ // @@protoc_insertion_point(builder_scope:eventmesh.common.protocol.grpc.Subscription)
+ }
+
+ // @@protoc_insertion_point(class_scope:eventmesh.common.protocol.grpc.Subscription)
+ private static final Subscription DEFAULT_INSTANCE;
+ static {
+ DEFAULT_INSTANCE = new Subscription();
+ }
+
+ public static Subscription getDefaultInstance() {
+ return DEFAULT_INSTANCE;
+ }
+
+ private static final com.google.protobuf.Parser
+ PARSER = new com.google.protobuf.AbstractParser() {
+ public Subscription parsePartialFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return new Subscription(input, extensionRegistry);
+ }
+ };
+
+ public static com.google.protobuf.Parser parser() {
+ return PARSER;
+ }
+
+ @Override
+ public com.google.protobuf.Parser getParserForType() {
+ return PARSER;
+ }
+
+ public Subscription getDefaultInstanceForType() {
+ return DEFAULT_INSTANCE;
+ }
+
+}
+
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java
new file mode 100644
index 0000000000..2f98079eb6
--- /dev/null
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/grpc/protos/SubscriptionOrBuilder.java
@@ -0,0 +1,66 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: eventmesh-client.proto
+
+package org.apache.eventmesh.common.protocol.grpc.protos;
+
+public interface SubscriptionOrBuilder extends
+ // @@protoc_insertion_point(interface_extends:eventmesh.common.protocol.grpc.Subscription)
+ com.google.protobuf.MessageOrBuilder {
+
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ boolean hasHeader();
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ RequestHeader getHeader();
+ /**
+ * .eventmesh.common.protocol.grpc.RequestHeader header = 1;
+ */
+ RequestHeaderOrBuilder getHeaderOrBuilder();
+
+ /**
+ * string consumerGroup = 2;
+ */
+ String getConsumerGroup();
+ /**
+ * string consumerGroup = 2;
+ */
+ com.google.protobuf.ByteString
+ getConsumerGroupBytes();
+
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ java.util.List
+ getSubscriptionItemsList();
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ Subscription.SubscriptionItem getSubscriptionItems(int index);
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ int getSubscriptionItemsCount();
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ java.util.List extends Subscription.SubscriptionItemOrBuilder>
+ getSubscriptionItemsOrBuilderList();
+ /**
+ * repeated .eventmesh.common.protocol.grpc.Subscription.SubscriptionItem subscriptionItems = 3;
+ */
+ Subscription.SubscriptionItemOrBuilder getSubscriptionItemsOrBuilder(
+ int index);
+
+ /**
+ * string url = 4;
+ */
+ String getUrl();
+ /**
+ * string url = 4;
+ */
+ com.google.protobuf.ByteString
+ getUrlBytes();
+}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/command/HttpCommand.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/HttpCommand.java
similarity index 82%
rename from eventmesh-common/src/main/java/org/apache/eventmesh/common/command/HttpCommand.java
rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/HttpCommand.java
index b6c61d68df..4b2d7b5816 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/command/HttpCommand.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/HttpCommand.java
@@ -15,19 +15,20 @@
* limitations under the License.
*/
-package org.apache.eventmesh.common.command;
+package org.apache.eventmesh.common.protocol.http;
import org.apache.eventmesh.common.Constants;
+import org.apache.eventmesh.common.protocol.ProtocolTransportObject;
import org.apache.eventmesh.common.protocol.http.body.BaseResponseBody;
import org.apache.eventmesh.common.protocol.http.body.Body;
+import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode;
import org.apache.eventmesh.common.protocol.http.header.BaseResponseHeader;
import org.apache.eventmesh.common.protocol.http.header.Header;
import org.apache.eventmesh.common.utils.JsonUtils;
-import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
-import java.util.Map;
+import java.util.Optional;
import java.util.concurrent.atomic.AtomicLong;
import io.netty.buffer.Unpooled;
@@ -38,9 +39,9 @@
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.handler.codec.http.HttpVersion;
-public class HttpCommand {
+public class HttpCommand implements ProtocolTransportObject {
- private static AtomicLong requestId = new AtomicLong(0);
+ private static final AtomicLong requestId = new AtomicLong(0);
private long opaque;
@@ -63,8 +64,7 @@ public class HttpCommand {
public CmdType cmdType = CmdType.REQ;
public HttpCommand() {
- this.reqTime = System.currentTimeMillis();
- this.opaque = requestId.incrementAndGet();
+ this(null, null, null);
}
public HttpCommand(String httpMethod, String httpVersion, String requestCode) {
@@ -75,8 +75,7 @@ public HttpCommand(String httpMethod, String httpVersion, String requestCode) {
this.opaque = requestId.incrementAndGet();
}
- public HttpCommand createHttpCommandResponse(Header header,
- Body body) {
+ public HttpCommand createHttpCommandResponse(Header header, Body body) {
if (StringUtils.isBlank(requestCode)) {
return null;
}
@@ -90,7 +89,7 @@ public HttpCommand createHttpCommandResponse(Header header,
return response;
}
- public HttpCommand createHttpCommandResponse(Integer retCode, String retMsg) {
+ public HttpCommand createHttpCommandResponse(EventMeshRetCode eventMeshRetCode) {
if (StringUtils.isBlank(requestCode)) {
return null;
}
@@ -101,8 +100,8 @@ public HttpCommand createHttpCommandResponse(Integer retCode, String retMsg) {
baseResponseHeader.setCode(requestCode);
response.setHeader(baseResponseHeader);
BaseResponseBody baseResponseBody = new BaseResponseBody();
- baseResponseBody.setRetCode(retCode);
- baseResponseBody.setRetMsg(retMsg);
+ baseResponseBody.setRetCode(eventMeshRetCode.getRetCode());
+ baseResponseBody.setRetMsg(eventMeshRetCode.getErrMsg());
response.setBody(baseResponseBody);
response.setCmdType(CmdType.RES);
response.setResTime(System.currentTimeMillis());
@@ -233,22 +232,13 @@ public DefaultFullHttpResponse httpResponse() throws Exception {
if (cmdType == CmdType.REQ) {
return null;
}
-
- DefaultFullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1,
- HttpResponseStatus.OK,
- Unpooled.wrappedBuffer(
- JsonUtils.serialize(this.getBody()).getBytes(Constants.DEFAULT_CHARSET)));
- response.headers().add(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.TEXT_PLAIN +
- "; charset=" + Constants.DEFAULT_CHARSET);
- response.headers().add(HttpHeaderNames.CONTENT_LENGTH, response.content().readableBytes());
- response.headers().add(HttpHeaderNames.CONNECTION, HttpHeaderValues.KEEP_ALIVE);
- Map customHeader = this.getHeader().toMap();
- if (MapUtils.isNotEmpty(customHeader)) {
- HttpHeaders heads = response.headers();
- for (String key : customHeader.keySet()) {
- heads.add(key, (customHeader.get(key) == null) ? "" : customHeader.get(key));
- }
- }
+ DefaultFullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK,
+ Unpooled.wrappedBuffer(JsonUtils.serialize(this.getBody()).getBytes(Constants.DEFAULT_CHARSET)));
+ HttpHeaders headers = response.headers();
+ headers.add(HttpHeaderNames.CONTENT_TYPE, "text/plain; charset=" + Constants.DEFAULT_CHARSET);
+ headers.add(HttpHeaderNames.CONTENT_LENGTH, response.content().readableBytes());
+ headers.add(HttpHeaderNames.CONNECTION, HttpHeaderValues.KEEP_ALIVE);
+ Optional.of(this.getHeader().toMap()).ifPresent(customerHeader -> customerHeader.forEach(headers::add));
return response;
}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/PushMessageRequestBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/PushMessageRequestBody.java
index fad1e95160..8e24580f39 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/PushMessageRequestBody.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/PushMessageRequestBody.java
@@ -32,7 +32,7 @@ public class PushMessageRequestBody extends Body {
public static final String RANDOMNO = "randomNo";
public static final String TOPIC = "topic";
- public static final String BIZSEQNO = "bizSeqNo";
+ public static final String BIZSEQNO = "bizseqno";
public static final String UNIQUEID = "uniqueId";
public static final String CONTENT = "content";
public static final String EXTFIELDS = "extFields";
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/ReplyMessageRequestBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/ReplyMessageRequestBody.java
index 93fa8b5f9a..90d83c1531 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/ReplyMessageRequestBody.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/ReplyMessageRequestBody.java
@@ -30,12 +30,12 @@
public class ReplyMessageRequestBody extends Body {
- public static final String ORIGTOPIC = "origTopic";
- public static final String BIZSEQNO = "bizSeqNo";
- public static final String UNIQUEID = "uniqueId";
+ public static final String ORIGTOPIC = "origtopic";
+ public static final String BIZSEQNO = "bizseqno";
+ public static final String UNIQUEID = "uniqueid";
public static final String CONTENT = "content";
public static final String EXTFIELDS = "extFields";
- public static final String PRODUCERGROUP = "producerGroup";
+ public static final String PRODUCERGROUP = "producergroup";
private String bizSeqNo;
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageBatchV2RequestBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageBatchV2RequestBody.java
index 8f97cf16c0..b08dca7b0c 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageBatchV2RequestBody.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageBatchV2RequestBody.java
@@ -25,12 +25,12 @@
public class SendMessageBatchV2RequestBody extends Body {
- public static final String BIZSEQNO = "bizSeqNo";
+ public static final String BIZSEQNO = "bizseqno";
public static final String TOPIC = "topic";
public static final String MSG = "msg";
public static final String TAG = "tag";
public static final String TTL = "ttl";
- public static final String PRODUCERGROUP = "producerGroup";
+ public static final String PRODUCERGROUP = "producergroup";
private String bizSeqNo;
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageRequestBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageRequestBody.java
index 196a9ccb84..25d35922a3 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageRequestBody.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageRequestBody.java
@@ -31,13 +31,13 @@
public class SendMessageRequestBody extends Body {
public static final String TOPIC = "topic";
- public static final String BIZSEQNO = "bizSeqNo";
- public static final String UNIQUEID = "uniqueId";
+ public static final String BIZSEQNO = "bizseqno";
+ public static final String UNIQUEID = "uniqueid";
public static final String CONTENT = "content";
public static final String TTL = "ttl";
public static final String TAG = "tag";
public static final String EXTFIELDS = "extFields";
- public static final String PRODUCERGROUP = "producerGroup";
+ public static final String PRODUCERGROUP = "producergroup";
private String topic;
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageResponseBody.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageResponseBody.java
index b9175a2c74..7a5f40dabd 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageResponseBody.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/body/message/SendMessageResponseBody.java
@@ -17,14 +17,18 @@
package org.apache.eventmesh.common.protocol.http.body.message;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.body.Body;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
+import org.apache.commons.lang3.time.DateFormatUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import lombok.Builder;
+import lombok.Data;
+
public class SendMessageResponseBody extends Body {
private Integer retCode;
@@ -69,9 +73,9 @@ public static SendMessageResponseBody buildBody(Integer retCode, String retMsg)
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("sendMessageResponseBody={")
- .append("retCode=").append(retCode).append(",")
- .append("retMsg=").append(retMsg).append(",")
- .append("resTime=").append(DateFormatUtils.format(resTime, Constants.DATE_FORMAT)).append("}");
+ .append("retCode=").append(retCode).append(",")
+ .append("retMsg=").append(retMsg).append(",")
+ .append("resTime=").append(DateFormatUtils.format(resTime, Constants.DATE_FORMAT)).append("}");
return sb.toString();
}
@@ -84,15 +88,11 @@ public Map toMap() {
return map;
}
+ @Data
+ @Builder
public static class ReplyMessage {
- public String topic;
- public String body;
+ public String topic;
+ public String body;
public Map properties;
-
- public ReplyMessage(String topic, String body, Map properties) {
- this.topic = topic;
- this.body = body;
- this.properties = properties;
- }
}
}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ProtocolKey.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ProtocolKey.java
index 28e944ea30..e032f1fe9a 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ProtocolKey.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/common/ProtocolKey.java
@@ -19,28 +19,36 @@
public class ProtocolKey {
- public static final String REQUEST_CODE = "Code";
- public static final String LANGUAGE = "Language";
- public static final String VERSION = "Version";
+ public static final String REQUEST_CODE = "code";
+ public static final String LANGUAGE = "language";
+ public static final String VERSION = "version";
+
+ public static final String PROTOCOL_TYPE = "protocoltype";
+
+ public static final String PROTOCOL_VERSION = "protocolversion";
+
+ public static final String PROTOCOL_DESC = "protocoldesc";
public static class ClientInstanceKey {
////////////////////////////////////Protocol layer requester description///////////
- public static final String ENV = "Env";
- public static final String IDC = "Idc";
- public static final String SYS = "Sys";
- public static final String PID = "Pid";
- public static final String IP = "Ip";
- public static final String USERNAME = "Username";
- public static final String PASSWD = "Passwd";
+ public static final String ENV = "env";
+ public static final String IDC = "idc";
+ public static final String SYS = "sys";
+ public static final String PID = "pid";
+ public static final String IP = "ip";
+ public static final String USERNAME = "username";
+ public static final String PASSWD = "passwd";
+ public static final String BIZSEQNO = "bizseqno";
+ public static final String UNIQUEID = "uniqueid";
}
public static class EventMeshInstanceKey {
///////////////////////////////////////////////Protocol layer EventMesh description
- public static final String EVENTMESHCLUSTER = "EventMeshCluster";
- public static final String EVENTMESHIP = "EventMeshIp";
- public static final String EVENTMESHENV = "EventMeshEnv";
- public static final String EVENTMESHIDC = "EventMeshIdc";
+ public static final String EVENTMESHCLUSTER = "eventmeshcluster";
+ public static final String EVENTMESHIP = "eventmeship";
+ public static final String EVENTMESHENV = "eventmeshenv";
+ public static final String EVENTMESHIDC = "eventmeshidc";
}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/ReplyMessageRequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/ReplyMessageRequestHeader.java
index d25936e279..496b1906cc 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/ReplyMessageRequestHeader.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/ReplyMessageRequestHeader.java
@@ -38,6 +38,15 @@ public class ReplyMessageRequestHeader extends Header {
//protocol version adopted by requester, default:1.0
private ProtocolVersion version;
+ //protocol type, cloudevents or eventmeshMessage
+ private String protocolType;
+
+ //protocol version, cloudevents:1.0 or 0.3
+ private String protocolVersion;
+
+ //protocol desc
+ private String protocolDesc;
+
//the environment number of the requester
private String env;
@@ -139,10 +148,37 @@ public void setIp(String ip) {
this.ip = ip;
}
+ public String getProtocolType() {
+ return protocolType;
+ }
+
+ public void setProtocolType(String protocolType) {
+ this.protocolType = protocolType;
+ }
+
+ public String getProtocolVersion() {
+ return protocolVersion;
+ }
+
+ public void setProtocolVersion(String protocolVersion) {
+ this.protocolVersion = protocolVersion;
+ }
+
+ public String getProtocolDesc() {
+ return protocolDesc;
+ }
+
+ public void setProtocolDesc(String protocolDesc) {
+ this.protocolDesc = protocolDesc;
+ }
+
public static ReplyMessageRequestHeader buildHeader(Map headerParam) {
ReplyMessageRequestHeader header = new ReplyMessageRequestHeader();
header.setCode(MapUtils.getString(headerParam, ProtocolKey.REQUEST_CODE));
header.setVersion(ProtocolVersion.get(MapUtils.getString(headerParam, ProtocolKey.VERSION)));
+ header.setProtocolType(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_TYPE));
+ header.setProtocolVersion(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_VERSION));
+ header.setProtocolDesc(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_DESC));
String lan = StringUtils.isBlank(MapUtils.getString(headerParam, ProtocolKey.LANGUAGE))
? Constants.LANGUAGE_JAVA : MapUtils.getString(headerParam, ProtocolKey.LANGUAGE);
header.setLanguage(lan);
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchRequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchRequestHeader.java
index 62cafa4226..85492cf2fc 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchRequestHeader.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchRequestHeader.java
@@ -39,6 +39,15 @@ public class SendMessageBatchRequestHeader extends Header {
//protocol version adopted by requester, default:1.0
private ProtocolVersion version;
+ //protocol type, cloudevents or eventmeshMessage
+ private String protocolType;
+
+ //protocol version, cloudevents:1.0 or 0.3
+ private String protocolVersion;
+
+ //protocol desc
+ private String protocolDesc;
+
//the environment number of the requester
private String env;
@@ -140,10 +149,37 @@ public void setIp(String ip) {
this.ip = ip;
}
+ public String getProtocolType() {
+ return protocolType;
+ }
+
+ public void setProtocolType(String protocolType) {
+ this.protocolType = protocolType;
+ }
+
+ public String getProtocolVersion() {
+ return protocolVersion;
+ }
+
+ public void setProtocolVersion(String protocolVersion) {
+ this.protocolVersion = protocolVersion;
+ }
+
+ public String getProtocolDesc() {
+ return protocolDesc;
+ }
+
+ public void setProtocolDesc(String protocolDesc) {
+ this.protocolDesc = protocolDesc;
+ }
+
public static SendMessageBatchRequestHeader buildHeader(final Map headerParam) {
SendMessageBatchRequestHeader header = new SendMessageBatchRequestHeader();
header.setCode(MapUtils.getString(headerParam, ProtocolKey.REQUEST_CODE));
header.setVersion(ProtocolVersion.get(MapUtils.getString(headerParam, ProtocolKey.VERSION)));
+ header.setProtocolType(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_TYPE));
+ header.setProtocolVersion(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_VERSION));
+ header.setProtocolDesc(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_DESC));
String lan = StringUtils.isBlank(MapUtils.getString(headerParam, ProtocolKey.LANGUAGE))
? Constants.LANGUAGE_JAVA : MapUtils.getString(headerParam, ProtocolKey.LANGUAGE);
header.setLanguage(lan);
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchV2RequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchV2RequestHeader.java
index b5d2e145e3..15ff19a623 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchV2RequestHeader.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageBatchV2RequestHeader.java
@@ -38,6 +38,15 @@ public class SendMessageBatchV2RequestHeader extends Header {
//protocol version adopted by requester, default:1.0
private ProtocolVersion version;
+ //protocol type, cloudevents or eventmeshMessage
+ private String protocolType;
+
+ //protocol version, cloudevents:1.0 or 0.3
+ private String protocolVersion;
+
+ //protocol desc
+ private String protocolDesc;
+
//the environment number of the requester
private String env;
@@ -139,10 +148,38 @@ public void setIp(String ip) {
this.ip = ip;
}
+ public String getProtocolType() {
+ return protocolType;
+ }
+
+ public void setProtocolType(String protocolType) {
+ this.protocolType = protocolType;
+ }
+
+ public String getProtocolVersion() {
+ return protocolVersion;
+ }
+
+ public void setProtocolVersion(String protocolVersion) {
+ this.protocolVersion = protocolVersion;
+ }
+
+ public String getProtocolDesc() {
+ return protocolDesc;
+ }
+
+ public void setProtocolDesc(String protocolDesc) {
+ this.protocolDesc = protocolDesc;
+ }
+
public static SendMessageBatchV2RequestHeader buildHeader(final Map headerParam) {
SendMessageBatchV2RequestHeader header = new SendMessageBatchV2RequestHeader();
header.setCode(MapUtils.getString(headerParam, ProtocolKey.REQUEST_CODE));
header.setVersion(ProtocolVersion.get(MapUtils.getString(headerParam, ProtocolKey.VERSION)));
+ header.setProtocolType(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_TYPE));
+ header.setProtocolVersion(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_VERSION));
+ header.setProtocolDesc(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_DESC));
+
String lan = StringUtils.isBlank(MapUtils.getString(headerParam, ProtocolKey.LANGUAGE))
? Constants.LANGUAGE_JAVA : MapUtils.getString(headerParam, ProtocolKey.LANGUAGE);
header.setLanguage(lan);
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageRequestHeader.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageRequestHeader.java
index 0eeea9afc2..f637563dc5 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageRequestHeader.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/http/header/message/SendMessageRequestHeader.java
@@ -38,6 +38,15 @@ public class SendMessageRequestHeader extends Header {
//protocol version adopted by requester, default:1.0
private ProtocolVersion version;
+ //protocol type, cloudevents or eventmeshMessage
+ private String protocolType;
+
+ //protocol version, cloudevents:1.0 or 0.3
+ private String protocolVersion;
+
+ //protocol desc
+ private String protocolDesc;
+
//the environment number of the requester
private String env;
@@ -139,10 +148,38 @@ public void setIp(String ip) {
this.ip = ip;
}
+ public String getProtocolType() {
+ return protocolType;
+ }
+
+ public void setProtocolType(String protocolType) {
+ this.protocolType = protocolType;
+ }
+
+ public String getProtocolVersion() {
+ return protocolVersion;
+ }
+
+ public void setProtocolVersion(String protocolVersion) {
+ this.protocolVersion = protocolVersion;
+ }
+
+ public String getProtocolDesc() {
+ return protocolDesc;
+ }
+
+ public void setProtocolDesc(String protocolDesc) {
+ this.protocolDesc = protocolDesc;
+ }
+
public static SendMessageRequestHeader buildHeader(Map headerParam) {
SendMessageRequestHeader header = new SendMessageRequestHeader();
header.setCode(MapUtils.getString(headerParam, ProtocolKey.REQUEST_CODE));
header.setVersion(ProtocolVersion.get(MapUtils.getString(headerParam, ProtocolKey.VERSION)));
+ header.setProtocolType(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_TYPE));
+ header.setProtocolVersion(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_VERSION));
+ header.setProtocolDesc(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_DESC));
+
String lan = StringUtils.isBlank(MapUtils.getString(headerParam, ProtocolKey.LANGUAGE))
? Constants.LANGUAGE_JAVA : MapUtils.getString(headerParam, ProtocolKey.LANGUAGE);
header.setLanguage(lan);
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/EventMeshMessage.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/EventMeshMessage.java
index 01d744eea1..a51f9e022a 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/EventMeshMessage.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/EventMeshMessage.java
@@ -20,51 +20,16 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-public class EventMeshMessage {
-
- private String topic;
- Map properties = new ConcurrentHashMap<>();
- private String body;
-
- public EventMeshMessage() {
- }
-
- public EventMeshMessage(String topic, Map properties, String body) {
- this.topic = topic;
- this.properties = properties;
- this.body = body;
- }
-
- public String getTopic() {
- return topic;
- }
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
- public Map getProperties() {
- return properties;
- }
-
- public void setProperties(Map properties) {
- this.properties = properties;
- }
-
- public String getBody() {
- return body;
- }
-
- public void setBody(String body) {
- this.body = body;
- }
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class EventMeshMessage {
- @Override
- public String toString() {
- return "EventMeshMessage{" +
- "topic='" + topic + '\'' +
- ", properties=" + properties +
- ", body='" + body + '\'' +
- '}';
- }
+ private String topic;
+ private Map properties = new ConcurrentHashMap<>();
+ private String body;
}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Header.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Header.java
index 1df51427c8..dc8e564382 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Header.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Header.java
@@ -17,62 +17,59 @@
package org.apache.eventmesh.common.protocol.tcp;
+import java.util.HashMap;
+import java.util.Map;
+
+import lombok.Data;
+
+@Data
public class Header {
- private Command cmd;
- private int code;
- private String msg;
- private String seq;
+ private Command cmd;
+ private int code;
+ private String desc;
+ private String seq;
+ private Map properties = new HashMap<>();
public Header() {
}
- public Header(Command cmd, int code, String msg, String seq) {
+ public Header(Command cmd, int code, String desc, String seq) {
this.cmd = cmd;
this.code = code;
- this.msg = msg;
+ this.desc = desc;
this.seq = seq;
}
- public Command getCommand() {
- return cmd;
- }
-
- public void setCommand(Command cmd) {
- this.cmd = cmd;
- }
-
- public int getCode() {
- return code;
- }
-
- public void setCode(int code) {
+ public Header(int code, String desc, String seq, Map properties) {
this.code = code;
+ this.desc = desc;
+ this.seq = seq;
+ this.properties = properties;
}
- public String getMsg() {
- return msg;
- }
- public void setMsg(String msg) {
- this.msg = msg;
- }
+ public void putProperty(final String name, final Object value) {
+ if (null == this.properties) {
+ this.properties = new HashMap<>();
+ }
- public String getSeq() {
- return seq;
+ this.properties.put(name, value);
}
- public void setSeq(String seq) {
- this.seq = seq;
+ public Object getProperty(final String name) {
+ if (null == this.properties) {
+ return null;
+ }
+ return this.properties.get(name);
}
- @Override
- public String toString() {
- return "Header{" +
- "cmd=" + cmd +
- ", code=" + code +
- ", msg='" + msg + '\'' +
- ", seq='" + seq + '\'' +
- '}';
+ public String getStringProperty(final String name) {
+ Object property = getProperty(name);
+ if (null == property) {
+ return null;
+ }
+ return property.toString();
}
+
}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Package.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Package.java
index d2cde02193..1a2a223bf2 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Package.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/Package.java
@@ -17,44 +17,22 @@
package org.apache.eventmesh.common.protocol.tcp;
-public class Package {
+import org.apache.eventmesh.common.protocol.ProtocolTransportObject;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class Package implements ProtocolTransportObject {
private Header header;
private Object body;
- public Package() {
- }
-
public Package(Header header) {
this.header = header;
}
- public Package(Header header, Object body) {
- this.header = header;
- this.body = body;
- }
-
- public Header getHeader() {
- return header;
- }
-
- public void setHeader(Header header) {
- this.header = header;
- }
-
- public Object getBody() {
- return body;
- }
-
- public void setBody(Object body) {
- this.body = body;
- }
-
- @Override
- public String toString() {
- return "Package{" +
- "header=" + header +
- ", body=" + body +
- '}';
- }
}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/UserAgent.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/UserAgent.java
index 14b5058e69..1d0c8d3fad 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/UserAgent.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/UserAgent.java
@@ -17,14 +17,21 @@
package org.apache.eventmesh.common.protocol.tcp;
+import lombok.Builder;
+import lombok.Data;
+
+import java.util.Objects;
+
+@Data
+@Builder
public class UserAgent {
private String env;
private String subsystem;
private String path;
- private int pid;
+ private int pid;
private String host;
- private int port;
+ private int port;
private String version;
private String username;
private String password;
@@ -32,137 +39,36 @@ public class UserAgent {
private String producerGroup;
private String consumerGroup;
private String purpose;
- private int unack = 0;
+ @Builder.Default
+ private int unack = 0;
public UserAgent() {
}
- public String getProducerGroup() {
- return producerGroup;
- }
-
- public void setProducerGroup(String producerGroup) {
- this.producerGroup = producerGroup;
- }
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-
- public String getEnv() {
- return env;
- }
-
- public void setEnv(String env) {
+ public UserAgent(String env, String subsystem, String path, int pid, String host, int port, String version,
+ String username, String password, String idc, String producerGroup, String consumerGroup,
+ String purpose, int unack) {
this.env = env;
- }
-
- public String getPurpose() {
- return purpose;
- }
-
- public void setPurpose(String purpose) {
- this.purpose = purpose;
- }
-
- public String getSubsystem() {
- return subsystem;
- }
-
- public void setSubsystem(String subsystem) {
this.subsystem = subsystem;
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
this.path = path;
- }
-
- public int getPid() {
- return pid;
- }
-
- public void setPid(int pid) {
this.pid = pid;
- }
-
- public String getHost() {
- return host;
- }
-
- public void setHost(String host) {
this.host = host;
- }
-
- public int getPort() {
- return port;
- }
-
- public void setPort(int port) {
this.port = port;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
this.version = version;
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
this.password = password;
- }
-
- public String getIdc() {
- return idc;
- }
-
- public void setIdc(String idc) {
this.idc = idc;
- }
-
- public int getUnack() {
- return unack;
- }
-
- public void setUnack(int unack) {
+ this.producerGroup = producerGroup;
+ this.consumerGroup = consumerGroup;
+ this.purpose = purpose;
this.unack = unack;
}
@Override
public String toString() {
- return "UserAgent{" +
- "env='" + env + '\'' +
- "subsystem='" + subsystem + '\'' +
- ", path='" + path + '\'' +
- ", pid=" + pid +
- ", host='" + host + '\'' +
- ", port=" + port +
- ", version='" + version + '\'' +
- ", idc='" + idc + '\'' +
- ", purpose='" + purpose + '\'' +
- ", unack='" + unack + '\'' +
- '}';
+ return String.format(
+ "UserAgent{env='%s', subsystem='%s', path='%s', pid=%d, host='%s', port=%d, version='%s', idc='%s', purpose='%s', unack='%d'}",
+ env, subsystem, path, pid, host, port, version, idc, purpose, unack);
}
@Override
@@ -175,15 +81,15 @@ public boolean equals(Object o) {
if (pid != userAgent.pid) return false;
if (port != userAgent.port) return false;
if (unack != userAgent.unack) return false;
- if (subsystem != null ? !subsystem.equals(userAgent.subsystem) : userAgent.subsystem != null) return false;
- if (path != null ? !path.equals(userAgent.path) : userAgent.path != null) return false;
- if (host != null ? !host.equals(userAgent.host) : userAgent.host != null) return false;
- if (purpose != null ? !purpose.equals(userAgent.purpose) : userAgent.purpose != null) return false;
- if (version != null ? !version.equals(userAgent.version) : userAgent.version != null) return false;
- if (username != null ? !username.equals(userAgent.username) : userAgent.username != null) return false;
- if (password != null ? !password.equals(userAgent.password) : userAgent.password != null) return false;
- if (env != null ? !env.equals(userAgent.env) : userAgent.env != null) return false;
- return idc != null ? idc.equals(userAgent.idc) : userAgent.idc == null;
+ if (!Objects.equals(subsystem, userAgent.subsystem)) return false;
+ if (!Objects.equals(path, userAgent.path)) return false;
+ if (!Objects.equals(host, userAgent.host)) return false;
+ if (!Objects.equals(purpose, userAgent.purpose)) return false;
+ if (!Objects.equals(version, userAgent.version)) return false;
+ if (!Objects.equals(username, userAgent.username)) return false;
+ if (!Objects.equals(password, userAgent.password)) return false;
+ if (!Objects.equals(env, userAgent.env)) return false;
+ return Objects.equals(idc, userAgent.idc);
}
@Override
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/codec/Codec.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/codec/Codec.java
index d520e04dbc..ab1d461207 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/codec/Codec.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/codec/Codec.java
@@ -17,67 +17,82 @@
package org.apache.eventmesh.common.protocol.tcp.codec;
+import org.apache.eventmesh.common.Constants;
+import org.apache.eventmesh.common.protocol.tcp.Command;
+import org.apache.eventmesh.common.protocol.tcp.Header;
+import org.apache.eventmesh.common.protocol.tcp.Package;
+import org.apache.eventmesh.common.protocol.tcp.RedirectInfo;
+import org.apache.eventmesh.common.protocol.tcp.Subscription;
+import org.apache.eventmesh.common.protocol.tcp.UserAgent;
+import org.apache.eventmesh.common.utils.JsonUtils;
+
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
+
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.List;
import java.util.TimeZone;
import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.handler.codec.ReplayingDecoder;
+import lombok.extern.slf4j.Slf4j;
-import org.apache.eventmesh.common.protocol.tcp.Command;
-import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage;
-import org.apache.eventmesh.common.protocol.tcp.Header;
-import org.apache.eventmesh.common.protocol.tcp.Package;
-import org.apache.eventmesh.common.protocol.tcp.RedirectInfo;
-import org.apache.eventmesh.common.protocol.tcp.Subscription;
-import org.apache.eventmesh.common.protocol.tcp.UserAgent;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
+@Slf4j
public class Codec {
- private final static Logger logger = LoggerFactory.getLogger(Codec.class);
- private static final int FRAME_MAX_LENGTH = 1024 * 1024 * 4;
- private static Charset UTF8 = Charset.forName("UTF-8");
+ private static final int FRAME_MAX_LENGTH = 1024 * 1024 * 4;
+ private static final Charset DEFAULT_CHARSET = Charset.forName(Constants.DEFAULT_CHARSET);
- private static final byte[] CONSTANT_MAGIC_FLAG = "EventMesh".getBytes(UTF8);
+ private static final byte[] CONSTANT_MAGIC_FLAG = serializeBytes("EventMesh");
+ private static final byte[] VERSION = serializeBytes("0000");
- private static final byte[] VERSION = "0000".getBytes(UTF8);
+ // todo: move to constants
+ public static String CLOUD_EVENTS_PROTOCOL_NAME = "cloudevents";
+ public static String EM_MESSAGE_PROTOCOL_NAME = "eventmeshmessage";
+ public static String OPEN_MESSAGE_PROTOCOL_NAME = "openmessage";
- private static ObjectMapper jsonMapper;
+ // todo: use json util
+ private static ObjectMapper OBJECT_MAPPER;
static {
- jsonMapper = new ObjectMapper();
- jsonMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
- jsonMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
- jsonMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
- jsonMapper.setTimeZone(TimeZone.getDefault());
+ OBJECT_MAPPER = new ObjectMapper();
+ OBJECT_MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ OBJECT_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
+ OBJECT_MAPPER.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
+ OBJECT_MAPPER.setTimeZone(TimeZone.getDefault());
}
public static class Encoder extends MessageToByteEncoder {
@Override
public void encode(ChannelHandlerContext ctx, Package pkg, ByteBuf out) throws Exception {
- byte[] headerData;
- byte[] bodyData;
-
- final String headerJson = pkg != null ? jsonMapper.writeValueAsString(pkg.getHeader()) : null;
- final String bodyJson = pkg != null ? jsonMapper.writeValueAsString(pkg.getBody()) : null;
+ Preconditions.checkNotNull(pkg, "TcpPackage cannot be null");
+ final Header header = pkg.getHeader();
+ Preconditions.checkNotNull(header, "TcpPackage header cannot be null", header);
+ if (log.isDebugEnabled()) {
+ log.debug("Encoder pkg={}", JsonUtils.serialize(pkg));
+ }
- headerData = headerJson == null ? null : headerJson.getBytes(UTF8);
- bodyData = bodyJson == null ? null : bodyJson.getBytes(UTF8);
+ final byte[] headerData = serializeBytes(OBJECT_MAPPER.writeValueAsString(header));
+ final byte[] bodyData;
- logger.debug("headerJson={}|bodyJson={}", headerJson, bodyJson);
+ if (StringUtils.equals(CLOUD_EVENTS_PROTOCOL_NAME, header.getStringProperty(Constants.PROTOCOL_TYPE))) {
+ bodyData = (byte[]) pkg.getBody();
+ } else {
+ bodyData = serializeBytes(OBJECT_MAPPER.writeValueAsString(pkg.getBody()));
+ }
- int headerLength = headerData == null ? 0 : headerData.length;
- int bodyLength = bodyData == null ? 0 : bodyData.length;
+ int headerLength = ArrayUtils.getLength(headerData);
+ int bodyLength = ArrayUtils.getLength(bodyData);
int length = 4 + 4 + headerLength + bodyLength;
@@ -89,94 +104,141 @@ public void encode(ChannelHandlerContext ctx, Package pkg, ByteBuf out) throws E
out.writeBytes(VERSION);
out.writeInt(length);
out.writeInt(headerLength);
- if (headerData != null)
+ if (headerData != null) {
out.writeBytes(headerData);
- if (bodyData != null)
+ }
+ if (bodyData != null) {
out.writeBytes(bodyData);
+ }
}
}
- public static class Decoder extends ReplayingDecoder {
+ public static class Decoder extends ReplayingDecoder {
@Override
public void decode(ChannelHandlerContext ctx, ByteBuf in, List out) throws Exception {
- Header header = null;
- Object body = null;
-
- int length = 0;
- int headerLength = 0;
- int bodyLength = 0;
-
try {
- if (null == in)
+ if (null == in) {
return;
-
- byte[] flagBytes = new byte[CONSTANT_MAGIC_FLAG.length];
- byte[] versionBytes = new byte[VERSION.length];
-
- in.readBytes(flagBytes);
- in.readBytes(versionBytes);
- if (!Arrays.equals(flagBytes, CONSTANT_MAGIC_FLAG) || !Arrays.equals(versionBytes, VERSION)) {
- String errorMsg = String.format("invalid magic flag or " +
- "version|flag=%s|version=%s|remoteAddress=%s", new String(flagBytes, UTF8), new String
- (versionBytes, UTF8), ctx.channel().remoteAddress());
- throw new Exception(errorMsg);
- }
-
- length = in.readInt();
- headerLength = in.readInt();
- bodyLength = length - 8 - headerLength;
- byte[] headerData = new byte[headerLength];
- byte[] bodyData = new byte[bodyLength];
-
- if (headerLength > 0) {
- in.readBytes(headerData);
- header = jsonMapper.readValue(new String(headerData, UTF8), Header.class);
}
- if (bodyLength > 0 && header != null) {
- in.readBytes(bodyData);
- body = parseFromJson(header.getCommand(), new String(bodyData, UTF8));
- }
+ byte[] flagBytes = parseFlag(in);
+ byte[] versionBytes = parseVersion(in);
+ validateFlag(flagBytes, versionBytes, ctx);
- logger.debug("headerJson={}|bodyJson={}", new String(headerData, UTF8), new String(bodyData, UTF8));
+ final int length = in.readInt();
+ final int headerLength = in.readInt();
+ final int bodyLength = length - 8 - headerLength;
+ Header header = parseHeader(in, headerLength);
+ Object body = parseBody(in, header, bodyLength);
Package pkg = new Package(header, body);
out.add(pkg);
} catch (Exception e) {
- logger.error("decode|length={}|headerLength={}|bodyLength={}|header={}|body={}.", length,
- headerLength, bodyLength, header, body);
+ log.error("decode error| receive: {}.", deserializeBytes(in.array()));
throw e;
}
}
+
+ private byte[] parseFlag(ByteBuf in) {
+ final byte[] flagBytes = new byte[CONSTANT_MAGIC_FLAG.length];
+ in.readBytes(flagBytes);
+ return flagBytes;
+ }
+
+ private byte[] parseVersion(ByteBuf in) {
+ final byte[] versionBytes = new byte[VERSION.length];
+ in.readBytes(versionBytes);
+ return versionBytes;
+ }
+
+ private Header parseHeader(ByteBuf in, int headerLength) throws JsonProcessingException {
+ if (headerLength <= 0) {
+ return null;
+ }
+ final byte[] headerData = new byte[headerLength];
+ in.readBytes(headerData);
+ if (log.isDebugEnabled()) {
+ log.debug("Decode headerJson={}", deserializeBytes(headerData));
+ }
+ return OBJECT_MAPPER.readValue(deserializeBytes(headerData), Header.class);
+ }
+
+ private Object parseBody(ByteBuf in, Header header, int bodyLength) throws JsonProcessingException {
+ if (bodyLength <= 0 || header == null) {
+ return null;
+ }
+ final byte[] bodyData = new byte[bodyLength];
+ in.readBytes(bodyData);
+ if (log.isDebugEnabled()) {
+ log.debug("Decode bodyJson={}", deserializeBytes(bodyData));
+ }
+ return deserializeBody(deserializeBytes(bodyData), header);
+ }
+
+ private void validateFlag(byte[] flagBytes, byte[] versionBytes, ChannelHandlerContext ctx) {
+ if (!Arrays.equals(flagBytes, CONSTANT_MAGIC_FLAG) || !Arrays.equals(versionBytes, VERSION)) {
+ String errorMsg = String.format(
+ "invalid magic flag or version|flag=%s|version=%s|remoteAddress=%s",
+ deserializeBytes(flagBytes), deserializeBytes(versionBytes), ctx.channel().remoteAddress());
+ throw new IllegalArgumentException(errorMsg);
+ }
+ }
}
- private static Object parseFromJson(Command cmd, String data) throws Exception {
- switch (cmd) {
+ private static Object deserializeBody(String bodyJsonString, Header header) throws JsonProcessingException {
+ Command command = header.getCmd();
+ switch (command) {
case HELLO_REQUEST:
case RECOMMEND_REQUEST:
- return jsonMapper.readValue(data, UserAgent.class);
+ return OBJECT_MAPPER.readValue(bodyJsonString, UserAgent.class);
case SUBSCRIBE_REQUEST:
case UNSUBSCRIBE_REQUEST:
- return jsonMapper.readValue(data, Subscription.class);
+ return OBJECT_MAPPER.readValue(bodyJsonString, Subscription.class);
case REQUEST_TO_SERVER:
case RESPONSE_TO_SERVER:
case ASYNC_MESSAGE_TO_SERVER:
case BROADCAST_MESSAGE_TO_SERVER:
- return jsonMapper.readValue(data, EventMeshMessage.class);
case REQUEST_TO_CLIENT:
case RESPONSE_TO_CLIENT:
case ASYNC_MESSAGE_TO_CLIENT:
case BROADCAST_MESSAGE_TO_CLIENT:
- return jsonMapper.readValue(data, EventMeshMessage.class);
case REQUEST_TO_CLIENT_ACK:
case RESPONSE_TO_CLIENT_ACK:
case ASYNC_MESSAGE_TO_CLIENT_ACK:
case BROADCAST_MESSAGE_TO_CLIENT_ACK:
- return jsonMapper.readValue(data, EventMeshMessage.class);
+ // The message string will be deserialized by protocol plugin, if the event is cloudevents, the body is
+ // just a string.
+ return bodyJsonString;
case REDIRECT_TO_CLIENT:
- return jsonMapper.readValue(data, RedirectInfo.class);
+ return OBJECT_MAPPER.readValue(bodyJsonString, RedirectInfo.class);
default:
+ log.warn("Invalidate TCP command: {}", command);
return null;
}
}
+
+ /**
+ * Deserialize bytes to String.
+ *
+ * @param bytes
+ * @return
+ */
+ private static String deserializeBytes(byte[] bytes) {
+ return new String(bytes, DEFAULT_CHARSET);
+ }
+
+ /**
+ * Serialize String to bytes.
+ *
+ * @param str
+ * @return
+ */
+ private static byte[] serializeBytes(String str) {
+ if (str == null) {
+ return null;
+ }
+ return str.getBytes(DEFAULT_CHARSET);
+ }
+
+
}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/IPUtil.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/IPUtils.java
similarity index 98%
rename from eventmesh-common/src/main/java/org/apache/eventmesh/common/IPUtil.java
rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/IPUtils.java
index 5165deb8af..434f5a580e 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/IPUtil.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/IPUtils.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.eventmesh.common;
+package org.apache.eventmesh.common.utils;
import java.net.Inet6Address;
import java.net.InetAddress;
@@ -30,7 +30,7 @@
import io.netty.channel.Channel;
-public class IPUtil {
+public class IPUtils {
public static String getLocalAddress() {
// if the progress works under docker environment
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/RandomStringUtil.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/RandomStringUtils.java
similarity index 76%
rename from eventmesh-common/src/main/java/org/apache/eventmesh/common/RandomStringUtil.java
rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/RandomStringUtils.java
index 802c3a6ccd..aaeaec84a6 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/RandomStringUtil.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/RandomStringUtils.java
@@ -15,17 +15,17 @@
* limitations under the License.
*/
-package org.apache.eventmesh.common;
+package org.apache.eventmesh.common.utils;
import org.apache.commons.text.RandomStringGenerator;
-public class RandomStringUtil {
+public class RandomStringUtils {
- private final static RandomStringGenerator randomNumGenerator = new RandomStringGenerator.Builder()
- .withinRange('0', '9').build();
+ private static final RandomStringGenerator RANDOM_NUM_GENERATOR = new RandomStringGenerator.Builder()
+ .withinRange('0', '9').build();
public static String generateNum(int length) {
- return randomNumGenerator.generate(length);
+ return RANDOM_NUM_GENERATOR.generate(length);
}
}
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadUtil.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/ThreadUtils.java
similarity index 70%
rename from eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadUtil.java
rename to eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/ThreadUtils.java
index 895215d0da..af69f08508 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/ThreadUtil.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/ThreadUtils.java
@@ -15,13 +15,15 @@
* limitations under the License.
*/
-package org.apache.eventmesh.common;
+package org.apache.eventmesh.common.utils;
+
+import org.apache.logging.log4j.util.ProcessIdUtil;
import java.util.concurrent.ThreadLocalRandom;
-public class ThreadUtil {
+public class ThreadUtils {
- private static long currentPID = -1;
+ private static volatile long currentPID = -1;
public static void randomSleep(int min, int max) throws Exception {
// nextInt is normally exclusive of the top value, so add 1 to make it inclusive
@@ -35,22 +37,18 @@ public static void randomSleep(int max) throws Exception {
}
/**
- * get current process id only once.
+ * get current process id.
*
* @return process id
*/
public static long getPID() {
- if (currentPID >= 0) {
- return currentPID;
- }
- String processName = java.lang.management.ManagementFactory.getRuntimeMXBean().getName();
- if (processName != null && processName.length() > 0) {
- try {
- currentPID = Long.parseLong(processName.split("@")[0]);
- } catch (Exception e) {
- return 0;
+ if (currentPID == -1) {
+ synchronized (ThreadUtils.class) {
+ if (currentPID == -1) {
+ currentPID = Long.parseLong(ProcessIdUtil.getProcessId());
+ }
}
}
- return 0;
+ return currentPID;
}
}
diff --git a/eventmesh-common/src/test/java/org/apache/eventmesh/common/LiteMessageTest.java b/eventmesh-common/src/test/java/org/apache/eventmesh/common/EventMeshMessageTest.java
similarity index 69%
rename from eventmesh-common/src/test/java/org/apache/eventmesh/common/LiteMessageTest.java
rename to eventmesh-common/src/test/java/org/apache/eventmesh/common/EventMeshMessageTest.java
index 2f206a8d82..006a1d1cb3 100644
--- a/eventmesh-common/src/test/java/org/apache/eventmesh/common/LiteMessageTest.java
+++ b/eventmesh-common/src/test/java/org/apache/eventmesh/common/EventMeshMessageTest.java
@@ -17,58 +17,58 @@
package org.apache.eventmesh.common;
-import org.junit.Assert;
-import org.junit.Test;
-
import java.util.HashMap;
import java.util.Map;
-public class LiteMessageTest {
+import org.junit.Assert;
+import org.junit.Test;
+
+public class EventMeshMessageTest {
@Test
public void testGetProp() {
- LiteMessage message = createLiteMessage();
+ EventMeshMessage message = createLiteMessage();
Assert.assertEquals(2L, message.getProp().size());
}
@Test
public void testSetProp() {
- LiteMessage message = createLiteMessage();
+ EventMeshMessage message = createLiteMessage();
Map prop = new HashMap<>();
prop.put("key3", "value3");
message.setProp(prop);
Assert.assertEquals(1L, message.getProp().size());
- Assert.assertEquals("value3", message.getPropKey("key3"));
+ Assert.assertEquals("value3", message.getProp("key3"));
}
@Test
public void testAddProp() {
- LiteMessage message = createLiteMessage();
+ EventMeshMessage message = createLiteMessage();
message.addProp("key3", "value3");
Assert.assertEquals(3L, message.getProp().size());
- Assert.assertEquals("value1", message.getPropKey("key1"));
+ Assert.assertEquals("value1", message.getProp("key1"));
}
@Test
public void testGetPropKey() {
- LiteMessage message = createLiteMessage();
- Assert.assertEquals("value1", message.getPropKey("key1"));
+ EventMeshMessage message = createLiteMessage();
+ Assert.assertEquals("value1", message.getProp("key1"));
}
@Test
public void testRemoveProp() {
- LiteMessage message = createLiteMessage();
- message.removeProp("key1");
+ EventMeshMessage message = createLiteMessage();
+ message.removePropIfPresent("key1");
Assert.assertEquals(1L, message.getProp().size());
- Assert.assertNull(message.getPropKey("key1"));
+ Assert.assertNull(message.getProp("key1"));
}
- private LiteMessage createLiteMessage() {
- LiteMessage result = new LiteMessage();
+ private EventMeshMessage createLiteMessage() {
Map prop = new HashMap<>();
prop.put("key1", "value1");
prop.put("key2", "value2");
- result.setProp(prop);
- return result;
+ return EventMeshMessage.builder()
+ .prop(prop)
+ .build();
}
}
diff --git a/eventmesh-common/src/test/java/org/apache/eventmesh/common/command/HttpCommandTest.java b/eventmesh-common/src/test/java/org/apache/eventmesh/common/protocol/http/HttpCommandTest.java
similarity index 86%
rename from eventmesh-common/src/test/java/org/apache/eventmesh/common/command/HttpCommandTest.java
rename to eventmesh-common/src/test/java/org/apache/eventmesh/common/protocol/http/HttpCommandTest.java
index ce5ac0c80b..962d6c7a79 100644
--- a/eventmesh-common/src/test/java/org/apache/eventmesh/common/command/HttpCommandTest.java
+++ b/eventmesh-common/src/test/java/org/apache/eventmesh/common/protocol/http/HttpCommandTest.java
@@ -15,13 +15,16 @@
* limitations under the License.
*/
-package org.apache.eventmesh.common.command;
+package org.apache.eventmesh.common.protocol.http;
+
+import static org.mockito.Mockito.when;
-import io.netty.handler.codec.http.DefaultFullHttpResponse;
-import io.netty.handler.codec.http.HttpHeaderNames;
-import org.apache.eventmesh.common.protocol.http.body.BaseResponseBody;
import org.apache.eventmesh.common.protocol.http.body.Body;
import org.apache.eventmesh.common.protocol.http.header.Header;
+
+import java.util.HashMap;
+import java.util.Map;
+
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -29,11 +32,8 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.mockito.Mockito.when;
+import io.netty.handler.codec.http.DefaultFullHttpResponse;
+import io.netty.handler.codec.http.HttpHeaderNames;
@RunWith(MockitoJUnitRunner.class)
public class HttpCommandTest {
@@ -63,13 +63,6 @@ public void testCreateHttpCommandResponseWithHeaderAndBody() {
Assert.assertEquals("value1", command.getHeader().toMap().get("key1"));
}
- @Test
- public void testCreateHttpCommandResponseWithRetCodeAndRetMsg() {
- HttpCommand command = httpCommand.createHttpCommandResponse(200, "SUCCESS");
- Assert.assertThat(((BaseResponseBody) command.getBody()).getRetCode(), is(200));
- Assert.assertEquals("SUCCESS", ((BaseResponseBody) command.getBody()).getRetMsg());
- }
-
@Test
public void testAbstractDesc() {
HttpCommand command = httpCommand.createHttpCommandResponse(header, body);
diff --git a/eventmesh-common/src/test/java/org/apache/eventmesh/common/IPUtilTest.java b/eventmesh-common/src/test/java/org/apache/eventmesh/common/utils/IPUtilsTest.java
similarity index 85%
rename from eventmesh-common/src/test/java/org/apache/eventmesh/common/IPUtilTest.java
rename to eventmesh-common/src/test/java/org/apache/eventmesh/common/utils/IPUtilsTest.java
index d4f4f97139..4adff4475d 100644
--- a/eventmesh-common/src/test/java/org/apache/eventmesh/common/IPUtilTest.java
+++ b/eventmesh-common/src/test/java/org/apache/eventmesh/common/utils/IPUtilsTest.java
@@ -15,24 +15,24 @@
* limitations under the License.
*/
-package org.apache.eventmesh.common;
+package org.apache.eventmesh.common.utils;
import org.junit.Assert;
import org.junit.Test;
import org.junit.contrib.java.lang.system.EnvironmentVariables;
-public class IPUtilTest {
+public class IPUtilsTest {
@Test
public void testDockerIP() {
EnvironmentVariables environmentVariables = new EnvironmentVariables();
environmentVariables.set("docker_host_ip", "dockHostIP");
- Assert.assertEquals("dockHostIP", IPUtil.getLocalAddress());
+ Assert.assertEquals("dockHostIP", IPUtils.getLocalAddress());
}
@Test
public void testLocalhostIP() {
- Assert.assertNotNull(IPUtil.getLocalAddress());
+ Assert.assertNotNull(IPUtils.getLocalAddress());
}
}
diff --git a/eventmesh-common/src/test/java/org/apache/eventmesh/common/ThreadUtilTest.java b/eventmesh-common/src/test/java/org/apache/eventmesh/common/utils/ThreadUtilsTest.java
similarity index 90%
rename from eventmesh-common/src/test/java/org/apache/eventmesh/common/ThreadUtilTest.java
rename to eventmesh-common/src/test/java/org/apache/eventmesh/common/utils/ThreadUtilsTest.java
index b888fde1e8..a9aeb0e38e 100644
--- a/eventmesh-common/src/test/java/org/apache/eventmesh/common/ThreadUtilTest.java
+++ b/eventmesh-common/src/test/java/org/apache/eventmesh/common/utils/ThreadUtilsTest.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package org.apache.eventmesh.common;
+package org.apache.eventmesh.common.utils;
import org.junit.Assert;
import org.junit.Test;
-public class ThreadUtilTest {
+public class ThreadUtilsTest {
@Test
public void testRandomSleep() throws InterruptedException {
@@ -33,7 +33,7 @@ public void testRandomSleep() throws InterruptedException {
@Test
public void testPID() {
- Assert.assertNotEquals(-1, ThreadUtil.getPID());
+ Assert.assertNotEquals(-1, ThreadUtils.getPID());
}
class TestThread extends Thread {
@@ -47,7 +47,7 @@ public long getSleepTime() {
public void run() {
long startTime = System.currentTimeMillis();
try {
- ThreadUtil.randomSleep(50);
+ ThreadUtils.randomSleep(50);
} catch (Exception ignore) {
}
sleepTime = System.currentTimeMillis() - startTime;
diff --git a/eventmesh-common/src/test/resources/configuration.properties b/eventmesh-common/src/test/resources/configuration.properties
index b8bf913d37..a5e0828ca3 100644
--- a/eventmesh-common/src/test/resources/configuration.properties
+++ b/eventmesh-common/src/test/resources/configuration.properties
@@ -23,4 +23,6 @@ eventMesh.server.name=value5
eventMesh.server.hostIp=value6
eventMesh.connector.plugin.type=rocketmq
eventMesh.security.plugin.type=acl
-eventMesh.registry.plugin.type=namesrv
\ No newline at end of file
+eventMesh.registry.plugin.type=namesrv
+eventmesh.trace.export.zipkin.ip=localhost
+eventmesh.trace.exporter.type=Zipkin
\ No newline at end of file
diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/build.gradle b/eventmesh-connector-plugin/eventmesh-connector-api/build.gradle
index 19cb54c18b..8ccfa87825 100644
--- a/eventmesh-connector-plugin/eventmesh-connector-api/build.gradle
+++ b/eventmesh-connector-plugin/eventmesh-connector-api/build.gradle
@@ -16,19 +16,18 @@
*/
dependencies {
- implementation project(":eventmesh-spi")
+ api project(":eventmesh-spi")
implementation project(":eventmesh-common")
- api 'io.openmessaging:openmessaging-api'
+ api 'io.cloudevents:cloudevents-core'
api 'io.dropwizard.metrics:metrics-core'
api "io.dropwizard.metrics:metrics-healthchecks"
api "io.dropwizard.metrics:metrics-annotation"
api "io.dropwizard.metrics:metrics-json"
- testImplementation project(":eventmesh-spi")
- testImplementation project(":eventmesh-common")
- testImplementation 'io.openmessaging:openmessaging-api'
- testImplementation 'io.dropwizard.metrics:metrics-core'
- testImplementation "io.dropwizard.metrics:metrics-healthchecks"
- testImplementation "io.dropwizard.metrics:metrics-annotation"
- testImplementation "io.dropwizard.metrics:metrics-json"
+ compileOnly 'org.projectlombok:lombok:1.18.22'
+ annotationProcessor 'org.projectlombok:lombok:1.18.22'
+
+ testCompileOnly 'org.projectlombok:lombok:1.18.22'
+ testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
+
}
diff --git a/eventmesh-schema-registry/build.gradle b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/AsyncConsumeContext.java
similarity index 85%
rename from eventmesh-schema-registry/build.gradle
rename to eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/AsyncConsumeContext.java
index 6a9c064171..7c1c739cd5 100644
--- a/eventmesh-schema-registry/build.gradle
+++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/AsyncConsumeContext.java
@@ -15,3 +15,11 @@
* limitations under the License.
*/
+package org.apache.eventmesh.api;
+
+
+public abstract class AsyncConsumeContext {
+
+ public abstract void commit(EventMeshAction action);
+
+}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventListener.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventListener.java
new file mode 100644
index 0000000000..eede41ca09
--- /dev/null
+++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventListener.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.api;
+
+
+import io.cloudevents.CloudEvent;
+
+/**
+ * Event listener, registered for consume messages by consumer.
+ *
+ *
+ *
+ * Thread safe requirements: this interface will be invoked by multi threads,
+ * so users should keep thread safe during the consume process.
+ *
+ *
+ */
+public interface EventListener {
+
+ void consume(final CloudEvent cloudEvent, final AsyncConsumeContext context);
+
+}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventMeshAction.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventMeshAction.java
index 4fda6d05b6..f783201086 100644
--- a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventMeshAction.java
+++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventMeshAction.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.eventmesh.api;
public enum EventMeshAction {
diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventMeshAsyncConsumeContext.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventMeshAsyncConsumeContext.java
index c7e4e7fb73..633a5b712b 100644
--- a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventMeshAsyncConsumeContext.java
+++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventMeshAsyncConsumeContext.java
@@ -14,10 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.eventmesh.api;
-import io.openmessaging.api.Action;
-import io.openmessaging.api.AsyncConsumeContext;
public abstract class EventMeshAsyncConsumeContext extends AsyncConsumeContext {
@@ -33,8 +32,4 @@ public void setAbstractContext(AbstractContext abstractContext) {
public abstract void commit(EventMeshAction action);
- @Override
- public void commit(Action action) {
- throw new UnsupportedOperationException("not support yet");
- }
}
\ No newline at end of file
diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/LifeCycle.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/LifeCycle.java
new file mode 100644
index 0000000000..f5d61de333
--- /dev/null
+++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/LifeCycle.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.api;
+
+import org.apache.eventmesh.api.consumer.Consumer;
+import org.apache.eventmesh.api.producer.Producer;
+
+/**
+ * The {@code LifeCycle} defines a lifecycle interface for a OMS related service endpoint,
+ * like {@link Producer}, {@link Consumer}, and so on.
+ */
+public interface LifeCycle {
+
+ boolean isStarted();
+
+ boolean isClosed();
+
+ void start();
+
+ void shutdown();
+}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/RRCallback.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/RequestReplyCallback.java
similarity index 84%
rename from eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/RRCallback.java
rename to eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/RequestReplyCallback.java
index 788f9f3906..3def887e07 100644
--- a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/RRCallback.java
+++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/RequestReplyCallback.java
@@ -17,12 +17,11 @@
package org.apache.eventmesh.api;
-import io.openmessaging.api.Message;
+import io.cloudevents.CloudEvent;
-public interface RRCallback {
+public interface RequestReplyCallback {
- public void onSuccess(Message msg);
-
- public void onException(Throwable e);
+ void onSuccess(CloudEvent event);
+ void onException(Throwable e);
}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/SendCallback.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/SendCallback.java
new file mode 100644
index 0000000000..c955f5d3aa
--- /dev/null
+++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/SendCallback.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.api;
+
+import org.apache.eventmesh.api.exception.OnExceptionContext;
+import org.apache.eventmesh.api.producer.Producer;
+
+import io.cloudevents.CloudEvent;
+
+/**
+ * Call back interface used in {@link Producer#sendAsync(CloudEvent, SendCallback)}.
+ */
+public interface SendCallback {
+
+ void onSuccess(final SendResult sendResult);
+
+ void onException(final OnExceptionContext context);
+}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/SendResult.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/SendResult.java
new file mode 100644
index 0000000000..1a68132c6b
--- /dev/null
+++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/SendResult.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.api;
+
+public class SendResult {
+ private String messageId;
+
+ private String topic;
+
+ public String getMessageId() {
+ return messageId;
+ }
+
+ public void setMessageId(String messageId) {
+ this.messageId = messageId;
+ }
+
+ public String getTopic() {
+ return topic;
+ }
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+ @Override
+ public String toString() {
+ return "SendResult[topic=" + topic + ", messageId=" + messageId + ']';
+ }
+}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/consumer/MeshMQPushConsumer.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/consumer/Consumer.java
similarity index 73%
rename from eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/consumer/MeshMQPushConsumer.java
rename to eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/consumer/Consumer.java
index dcf558b685..87b3ac7bba 100644
--- a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/consumer/MeshMQPushConsumer.java
+++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/consumer/Consumer.java
@@ -17,28 +17,28 @@
package org.apache.eventmesh.api.consumer;
-import java.util.List;
-import java.util.Properties;
-
-import io.openmessaging.api.AsyncMessageListener;
-import io.openmessaging.api.Consumer;
-import io.openmessaging.api.Message;
-
import org.apache.eventmesh.api.AbstractContext;
+import org.apache.eventmesh.api.EventListener;
+import org.apache.eventmesh.api.LifeCycle;
import org.apache.eventmesh.spi.EventMeshExtensionType;
import org.apache.eventmesh.spi.EventMeshSPI;
+import java.util.List;
+import java.util.Properties;
+
+import io.cloudevents.CloudEvent;
+
+/**
+ * Consumer Interface.
+ */
@EventMeshSPI(isSingleton = false, eventMeshExtensionType = EventMeshExtensionType.CONNECTOR)
-public interface MeshMQPushConsumer extends Consumer {
+public interface Consumer extends LifeCycle {
void init(Properties keyValue) throws Exception;
- void updateOffset(List msgs, AbstractContext context);
-
-// void registerMessageListener(MessageListenerConcurrently messageListenerConcurrently);
+ void updateOffset(List cloudEvents, AbstractContext context);
- void subscribe(String topic, final AsyncMessageListener listener) throws Exception;
+ void subscribe(String topic, final EventListener listener) throws Exception;
- @Override
void unsubscribe(String topic);
}
diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/Schema.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/exception/ConnectorRuntimeException.java
similarity index 64%
rename from eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/Schema.java
rename to eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/exception/ConnectorRuntimeException.java
index a46b2cd5d3..0efe513652 100644
--- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/Schema.java
+++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/exception/ConnectorRuntimeException.java
@@ -14,30 +14,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.eventmesh.schema.registry.server.domain;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
+package org.apache.eventmesh.api.exception;
-@Data
-@AllArgsConstructor
-@NoArgsConstructor
-public class Schema {
+public class ConnectorRuntimeException extends RuntimeException {
- private String id;
+ public ConnectorRuntimeException() {
- private String name;
+ }
- private String comment;
+ public ConnectorRuntimeException(String message) {
+ super(message);
+ }
- private String serialization;
+ public ConnectorRuntimeException(Throwable throwable) {
+ super(throwable);
+ }
- private String schemaType;
+ public ConnectorRuntimeException(String message, Throwable throwable) {
+ super(message, throwable);
+ }
- private String schemaDefinition;
-
- private String validator;
-
- private int version;
}
diff --git a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/Compatibility.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/exception/OnExceptionContext.java
similarity index 77%
rename from eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/Compatibility.java
rename to eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/exception/OnExceptionContext.java
index 2e3c829510..d51da7a0d1 100644
--- a/eventmesh-schema-registry/eventmesh-schema-registry-server/src/main/java/org/apache/eventmesh/schema/registry/server/domain/Compatibility.java
+++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/exception/OnExceptionContext.java
@@ -14,15 +14,26 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.eventmesh.schema.registry.server.domain;
+
+package org.apache.eventmesh.api.exception;
import lombok.AllArgsConstructor;
+import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
-@AllArgsConstructor
+@Builder
@NoArgsConstructor
-public class Compatibility {
- private String compatibility;
+@AllArgsConstructor
+public class OnExceptionContext {
+
+ private String messageId;
+
+ private String topic;
+
+ /**
+ * Detailed exception stack information.
+ */
+ private ConnectorRuntimeException exception;
}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/factory/ConnectorPluginFactory.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/factory/ConnectorPluginFactory.java
index cff0c8edcc..0793634771 100644
--- a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/factory/ConnectorPluginFactory.java
+++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/factory/ConnectorPluginFactory.java
@@ -19,12 +19,12 @@
package org.apache.eventmesh.api.factory;
-import org.apache.eventmesh.api.consumer.MeshMQPushConsumer;
-import org.apache.eventmesh.api.producer.MeshMQProducer;
+import org.apache.eventmesh.api.consumer.Consumer;
+import org.apache.eventmesh.api.producer.Producer;
import org.apache.eventmesh.spi.EventMeshExtensionFactory;
/**
- * The factory to get connector {@link MeshMQProducer} and {@link MeshMQPushConsumer}
+ * The factory to get connector {@link Producer} and {@link Consumer}
*/
public class ConnectorPluginFactory {
@@ -34,8 +34,8 @@ public class ConnectorPluginFactory {
* @param connectorPluginName plugin name
* @return MeshMQProducer instance
*/
- public static MeshMQProducer getMeshMQProducer(String connectorPluginName) {
- return EventMeshExtensionFactory.getExtension(MeshMQProducer.class, connectorPluginName);
+ public static Producer getMeshMQProducer(String connectorPluginName) {
+ return EventMeshExtensionFactory.getExtension(Producer.class, connectorPluginName);
}
/**
@@ -44,8 +44,8 @@ public static MeshMQProducer getMeshMQProducer(String connectorPluginName) {
* @param connectorPluginName plugin name
* @return MeshMQPushConsumer instance
*/
- public static MeshMQPushConsumer getMeshMQPushConsumer(String connectorPluginName) {
- return EventMeshExtensionFactory.getExtension(MeshMQPushConsumer.class, connectorPluginName);
+ public static Consumer getMeshMQPushConsumer(String connectorPluginName) {
+ return EventMeshExtensionFactory.getExtension(Consumer.class, connectorPluginName);
}
private static T getPlugin(Class pluginType, String pluginName) {
diff --git a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/producer/MeshMQProducer.java b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/producer/Producer.java
similarity index 61%
rename from eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/producer/MeshMQProducer.java
rename to eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/producer/Producer.java
index d87be7d842..c526215435 100644
--- a/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/producer/MeshMQProducer.java
+++ b/eventmesh-connector-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/producer/Producer.java
@@ -17,29 +17,38 @@
package org.apache.eventmesh.api.producer;
-import java.util.Properties;
-
-import io.openmessaging.api.Message;
-import io.openmessaging.api.Producer;
-import io.openmessaging.api.SendCallback;
-
-import org.apache.eventmesh.api.RRCallback;
+import org.apache.eventmesh.api.LifeCycle;
+import org.apache.eventmesh.api.RequestReplyCallback;
+import org.apache.eventmesh.api.SendCallback;
+import org.apache.eventmesh.api.SendResult;
import org.apache.eventmesh.spi.EventMeshExtensionType;
import org.apache.eventmesh.spi.EventMeshSPI;
+import java.util.Properties;
+
+import io.cloudevents.CloudEvent;
+
+/**
+ * Producer Interface.
+ */
@EventMeshSPI(isSingleton = false, eventMeshExtensionType = EventMeshExtensionType.CONNECTOR)
-public interface MeshMQProducer extends Producer {
+public interface Producer extends LifeCycle {
void init(Properties properties) throws Exception;
- void send(Message message, SendCallback sendCallback) throws Exception;
+ SendResult publish(final CloudEvent cloudEvent);
+
+ void publish(CloudEvent cloudEvent, SendCallback sendCallback) throws Exception;
+
+ void sendOneway(final CloudEvent cloudEvent);
- void request(Message message, RRCallback rrCallback, long timeout) throws Exception;
+ void sendAsync(final CloudEvent cloudEvent, final SendCallback sendCallback);
- boolean reply(final Message message, final SendCallback sendCallback) throws Exception;
+ void request(CloudEvent cloudEvent, RequestReplyCallback rrCallback, long timeout) throws Exception;
+
+ boolean reply(final CloudEvent cloudEvent, final SendCallback sendCallback) throws Exception;
void checkTopicExist(String topic) throws Exception;
void setExtFields();
-
}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/build.gradle b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/build.gradle
index eb722cc890..45e6bdd40c 100644
--- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/build.gradle
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/build.gradle
@@ -17,6 +17,7 @@
configurations {
implementation.exclude group: 'ch.qos.logback', module: 'logback-classic'
+ implementation.exclude group: 'log4j', module: 'log4j'
}
List rocketmq = [
@@ -37,8 +38,8 @@ List rocketmq = [
]
dependencies {
- compileOnly project(":eventmesh-common")
- compileOnly project(":eventmesh-connector-plugin:eventmesh-connector-api")
+ implementation project(":eventmesh-common")
+ implementation project(":eventmesh-connector-plugin:eventmesh-connector-api")
implementation rocketmq
testImplementation project(":eventmesh-connector-plugin:eventmesh-connector-api")
@@ -49,4 +50,10 @@ dependencies {
testImplementation "org.powermock:powermock-api-mockito2"
testImplementation rocketmq
+
+ compileOnly 'org.projectlombok:lombok:1.18.22'
+ annotationProcessor 'org.projectlombok:lombok:1.18.22'
+
+ testCompileOnly 'org.projectlombok:lombok:1.18.22'
+ testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/MessagingAccessPointImpl.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/MessagingAccessPointImpl.java
index f1b7ec79f1..06999487d3 100644
--- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/MessagingAccessPointImpl.java
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/MessagingAccessPointImpl.java
@@ -1,93 +1,90 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.eventmesh.connector.rocketmq;
-
-import java.util.Properties;
-
-import io.openmessaging.api.Consumer;
-import io.openmessaging.api.MessagingAccessPoint;
-import io.openmessaging.api.Producer;
-import io.openmessaging.api.PullConsumer;
-import io.openmessaging.api.batch.BatchConsumer;
-import io.openmessaging.api.order.OrderConsumer;
-import io.openmessaging.api.order.OrderProducer;
-import io.openmessaging.api.transaction.LocalTransactionChecker;
-import io.openmessaging.api.transaction.TransactionProducer;
-
-import org.apache.eventmesh.connector.rocketmq.consumer.PushConsumerImpl;
-import org.apache.eventmesh.connector.rocketmq.producer.ProducerImpl;
-
-public class MessagingAccessPointImpl implements MessagingAccessPoint {
-
- private Properties accessPointProperties;
-
- public MessagingAccessPointImpl(final Properties accessPointProperties) {
- this.accessPointProperties = accessPointProperties;
- }
-
- @Override
- public String version() {
- return null;
- }
-
- @Override
- public Properties attributes() {
- return accessPointProperties;
- }
-
- @Override
- public Producer createProducer(Properties properties) {
- return new ProducerImpl(this.accessPointProperties);
- }
-
- @Override
- public OrderProducer createOrderProducer(Properties properties) {
- return null;
- }
-
- @Override
- public TransactionProducer createTransactionProducer(Properties properties, LocalTransactionChecker checker) {
- return null;
- }
-
- @Override
- public TransactionProducer createTransactionProducer(Properties properties) {
- return null;
- }
-
- @Override
- public Consumer createConsumer(Properties properties) {
- return new PushConsumerImpl(properties);
- }
-
- @Override
- public PullConsumer createPullConsumer(Properties properties) {
- return null;
- }
-
- @Override
- public BatchConsumer createBatchConsumer(Properties properties) {
- return null;
- }
-
- @Override
- public OrderConsumer createOrderedConsumer(Properties properties) {
- return null;
- }
-
-}
+///*
+// * Licensed to the Apache Software Foundation (ASF) under one or more
+// * contributor license agreements. See the NOTICE file distributed with
+// * this work for additional information regarding copyright ownership.
+// * The ASF licenses this file to You under the Apache License, Version 2.0
+// * (the "License"); you may not use this file except in compliance with
+// * the License. You may obtain a copy of the License at
+// *
+// * http://www.apache.org/licenses/LICENSE-2.0
+// *
+// * Unless required by applicable law or agreed to in writing, software
+// * distributed under the License is distributed on an "AS IS" BASIS,
+// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// * See the License for the specific language governing permissions and
+// * limitations under the License.
+// */
+//
+//package org.apache.eventmesh.connector.rocketmq;
+//
+//import java.util.Properties;
+//
+//import io.openmessaging.api.Consumer;
+//import io.openmessaging.api.MessagingAccessPoint;
+//import io.openmessaging.api.Producer;
+//import io.openmessaging.api.PullConsumer;
+//import io.openmessaging.api.batch.BatchConsumer;
+//import io.openmessaging.api.order.OrderConsumer;
+//import io.openmessaging.api.order.OrderProducer;
+//import io.openmessaging.api.transaction.LocalTransactionChecker;
+//import io.openmessaging.api.transaction.TransactionProducer;
+//
+//public class MessagingAccessPointImpl implements MessagingAccessPoint {
+//
+// private Properties accessPointProperties;
+//
+// public MessagingAccessPointImpl(final Properties accessPointProperties) {
+// this.accessPointProperties = accessPointProperties;
+// }
+//
+// @Override
+// public String version() {
+// return null;
+// }
+//
+// @Override
+// public Properties attributes() {
+// return accessPointProperties;
+// }
+//
+// @Override
+// public Producer createProducer(Properties properties) {
+// return null;
+// }
+//
+// @Override
+// public OrderProducer createOrderProducer(Properties properties) {
+// return null;
+// }
+//
+// @Override
+// public TransactionProducer createTransactionProducer(Properties properties, LocalTransactionChecker checker) {
+// return null;
+// }
+//
+// @Override
+// public TransactionProducer createTransactionProducer(Properties properties) {
+// return null;
+// }
+//
+// @Override
+// public Consumer createConsumer(Properties properties) {
+// return null;
+// }
+//
+// @Override
+// public PullConsumer createPullConsumer(Properties properties) {
+// return null;
+// }
+//
+// @Override
+// public BatchConsumer createBatchConsumer(Properties properties) {
+// return null;
+// }
+//
+// @Override
+// public OrderConsumer createOrderedConsumer(Properties properties) {
+// return null;
+// }
+//
+//}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/admin/command/Command.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/admin/command/Command.java
new file mode 100644
index 0000000000..9f3b5e9e60
--- /dev/null
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/admin/command/Command.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.rocketmq.admin.command;
+
+import org.apache.eventmesh.connector.rocketmq.config.ClientConfiguration;
+
+import org.apache.rocketmq.acl.common.AclClientRPCHook;
+import org.apache.rocketmq.acl.common.SessionCredentials;
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
+
+import java.util.UUID;
+
+public abstract class Command {
+ protected DefaultMQAdminExt adminExt;
+
+ protected String nameServerAddr;
+ protected String clusterName;
+
+ public void init() {
+ final ClientConfiguration clientConfiguration = new ClientConfiguration();
+ clientConfiguration.init();
+
+ nameServerAddr = clientConfiguration.namesrvAddr;
+ clusterName = clientConfiguration.clusterName;
+ String accessKey = clientConfiguration.accessKey;
+ String secretKey = clientConfiguration.secretKey;
+
+ RPCHook rpcHook = new AclClientRPCHook(new SessionCredentials(accessKey, secretKey));
+ adminExt = new DefaultMQAdminExt(rpcHook);
+ String groupId = UUID.randomUUID().toString();
+ adminExt.setAdminExtGroup("admin_ext_group-" + groupId);
+ adminExt.setNamesrvAddr(nameServerAddr);
+ }
+
+ public abstract void execute() throws Exception;
+}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/admin/command/CreateTopicCommand.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/admin/command/CreateTopicCommand.java
new file mode 100644
index 0000000000..53f1822560
--- /dev/null
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/admin/command/CreateTopicCommand.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.rocketmq.admin.command;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.rocketmq.common.TopicConfig;
+import org.apache.rocketmq.tools.command.CommandUtil;
+
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CreateTopicCommand extends Command {
+ public Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ private int numOfQueue = 4;
+ private int queuePermission = 6;
+ private String topicName = "";
+
+ @Override
+ public void execute() throws Exception {
+ if (StringUtils.isBlank(topicName)) {
+ logger.error("Topic name can not be blank.");
+ throw new Exception("Topic name can not be blank.");
+ }
+ try {
+ init();
+ adminExt.start();
+ Set brokersAddr = CommandUtil.fetchMasterAddrByClusterName(
+ adminExt, clusterName);
+ for (String masterAddr : brokersAddr) {
+ TopicConfig topicConfig = new TopicConfig();
+ topicConfig.setTopicName(topicName);
+ topicConfig.setReadQueueNums(numOfQueue);
+ topicConfig.setWriteQueueNums(numOfQueue);
+ topicConfig.setPerm(queuePermission);
+ adminExt.createAndUpdateTopicConfig(masterAddr, topicConfig);
+ logger.info("Topic {} is created for RocketMQ broker {}", topicName, masterAddr);
+ }
+ } finally {
+ adminExt.shutdown();
+ }
+ }
+
+ public int getNumOfQueue() {
+ return numOfQueue;
+ }
+
+ public int getQueuePermission() {
+ return queuePermission;
+ }
+
+ public String getTopicName() {
+ return topicName;
+ }
+
+ public void setTopicName(String topicName) {
+ this.topicName = topicName;
+ }
+
+ public void setNumOfQueue(int numOfQueue) {
+ this.numOfQueue = numOfQueue;
+ }
+
+ public void setQueuePermission(int permission) {
+ this.queuePermission = permission;
+ }
+}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/RocketMQMessageFactory.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/RocketMQMessageFactory.java
new file mode 100644
index 0000000000..966be12844
--- /dev/null
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/RocketMQMessageFactory.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.rocketmq.cloudevent;
+
+import org.apache.rocketmq.common.message.Message;
+
+import java.util.Map;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import io.cloudevents.core.message.MessageReader;
+import io.cloudevents.core.message.MessageWriter;
+import io.cloudevents.core.message.impl.GenericStructuredMessageReader;
+import io.cloudevents.core.message.impl.MessageUtils;
+import io.cloudevents.lang.Nullable;
+import io.cloudevents.rw.CloudEventRWException;
+import io.cloudevents.rw.CloudEventWriter;
+
+import org.apache.eventmesh.connector.rocketmq.cloudevent.impl.RocketMQBinaryMessageReader;
+import org.apache.eventmesh.connector.rocketmq.cloudevent.impl.RocketMQHeaders;
+import org.apache.eventmesh.connector.rocketmq.cloudevent.impl.RocketMQMessageWriter;
+
+
+@ParametersAreNonnullByDefault
+public final class RocketMQMessageFactory {
+
+ private RocketMQMessageFactory() {
+ // prevent instantiation
+ }
+
+ public static MessageReader createReader(final Message message) throws CloudEventRWException {
+ return createReader(message.getProperties(), message.getBody());
+ }
+
+
+ public static MessageReader createReader(final Map props,
+ @Nullable final byte[] body)
+ throws CloudEventRWException {
+
+ return MessageUtils.parseStructuredOrBinaryMessage(
+ () -> null,
+ format -> null,
+ () -> props.get(RocketMQHeaders.SPEC_VERSION),
+ sv -> new RocketMQBinaryMessageReader(sv, props, body)
+ );
+ }
+
+
+ public static MessageWriter, Message> createWriter(String topic) {
+ return new RocketMQMessageWriter<>(topic);
+ }
+
+ public static MessageWriter, Message> createWriter(String topic,
+ String keys) {
+ return new RocketMQMessageWriter<>(topic, keys);
+ }
+
+ public static MessageWriter, Message> createWriter(String topic,
+ String keys,
+ String tags) {
+ return new RocketMQMessageWriter<>(topic, keys, tags);
+ }
+
+}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/impl/RocketMQBinaryMessageReader.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/impl/RocketMQBinaryMessageReader.java
new file mode 100644
index 0000000000..8b120380b5
--- /dev/null
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/impl/RocketMQBinaryMessageReader.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.rocketmq.cloudevent.impl;
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.function.BiConsumer;
+
+import io.cloudevents.SpecVersion;
+import io.cloudevents.core.data.BytesCloudEventData;
+import io.cloudevents.core.message.impl.BaseGenericBinaryMessageReaderImpl;
+
+public class RocketMQBinaryMessageReader
+ extends BaseGenericBinaryMessageReaderImpl {
+
+ private final Map headers;
+
+ public RocketMQBinaryMessageReader(SpecVersion version, Map headers,
+ byte[] payload) {
+ super(version,
+ payload != null && payload.length > 0 ? BytesCloudEventData.wrap(payload) : null);
+
+ Objects.requireNonNull(headers);
+ this.headers = headers;
+ }
+
+ @Override
+ protected boolean isContentTypeHeader(String key) {
+ return key.equals(RocketMQHeaders.CONTENT_TYPE);
+ }
+
+ @Override
+ protected boolean isCloudEventsHeader(String key) {
+ // return key.length() > 3 && key.substring(0, RocketMQHeaders.CE_PREFIX.length())
+ //.startsWith(RocketMQHeaders.CE_PREFIX);
+ return true;
+ }
+
+ @Override
+ protected String toCloudEventsKey(String key) {
+ //return key.substring(RocketMQHeaders.CE_PREFIX.length()).toLowerCase();
+ return key.toLowerCase();
+ }
+
+ @Override
+ protected void forEachHeader(BiConsumer fn) {
+ this.headers.forEach((k, v) -> fn.accept(k, v));
+ }
+
+ @Override
+ protected String toCloudEventsValue(String value) {
+ return value;
+ }
+}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/impl/RocketMQHeaders.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/impl/RocketMQHeaders.java
new file mode 100644
index 0000000000..64600ae0a7
--- /dev/null
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/impl/RocketMQHeaders.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.rocketmq.cloudevent.impl;
+
+import java.util.Map;
+
+import io.cloudevents.core.message.impl.MessageUtils;
+import io.cloudevents.core.v1.CloudEventV1;
+
+public class RocketMQHeaders {
+
+ public static final String CE_PREFIX = "CE_";
+
+ protected static final Map ATTRIBUTES_TO_HEADERS =
+ MessageUtils.generateAttributesToHeadersMapping(v -> v);
+
+ public static final String CONTENT_TYPE =
+ ATTRIBUTES_TO_HEADERS.get(CloudEventV1.DATACONTENTTYPE);
+
+ public static final String SPEC_VERSION = ATTRIBUTES_TO_HEADERS.get(CloudEventV1.SPECVERSION);
+
+
+}
+
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/impl/RocketMQMessageWriter.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/impl/RocketMQMessageWriter.java
new file mode 100644
index 0000000000..60f0609a36
--- /dev/null
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/cloudevent/impl/RocketMQMessageWriter.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.rocketmq.cloudevent.impl;
+
+import org.apache.rocketmq.common.message.Message;
+
+import io.cloudevents.CloudEventData;
+import io.cloudevents.SpecVersion;
+import io.cloudevents.core.format.EventFormat;
+import io.cloudevents.core.message.MessageWriter;
+import io.cloudevents.rw.CloudEventContextWriter;
+import io.cloudevents.rw.CloudEventRWException;
+import io.cloudevents.rw.CloudEventWriter;
+
+
+public final class RocketMQMessageWriter
+ implements MessageWriter, Message>, CloudEventWriter {
+
+ private Message message;
+
+
+ public RocketMQMessageWriter(String topic) {
+ message = new Message();
+ message.setTopic(topic);
+ }
+
+ public RocketMQMessageWriter(String topic, String keys) {
+ message = new Message();
+
+ message.setTopic(topic);
+
+ if (keys != null && keys.length() > 0) {
+ message.setKeys(keys);
+ }
+ }
+
+ public RocketMQMessageWriter(String topic, String keys, String tags) {
+ message = new Message();
+
+ message.setTopic(topic);
+
+ if (tags != null && tags.length() > 0) {
+ message.setTags(tags);
+ }
+
+ if (keys != null && keys.length() > 0) {
+ message.setKeys(keys);
+ }
+ }
+
+
+ @Override
+ public CloudEventContextWriter withContextAttribute(String name, String value)
+ throws CloudEventRWException {
+
+ //String propName = RocketMQHeaders.ATTRIBUTES_TO_HEADERS.get(name);
+ //if (propName == null) {
+ //propName = RocketMQHeaders.CE_PREFIX + name;
+ //}
+ //message.putUserProperty(propName, value);
+ message.putUserProperty(name, value);
+ return this;
+ }
+
+ @Override
+ public RocketMQMessageWriter create(final SpecVersion version) {
+ message.putUserProperty(RocketMQHeaders.SPEC_VERSION, version.toString());
+ return this;
+ }
+
+ @Override
+ public Message setEvent(final EventFormat format, final byte[] value)
+ throws CloudEventRWException {
+ message.putUserProperty(RocketMQHeaders.CONTENT_TYPE, format.serializedContentType());
+ message.setBody(value);
+ return message;
+ }
+
+ @Override
+ public Message end(final CloudEventData data) throws CloudEventRWException {
+ message.setBody(data.toBytes());
+ return message;
+ }
+
+ @Override
+ public Message end() {
+ message.setBody(null);
+ return message;
+ }
+}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/common/EventMeshConstants.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/common/EventMeshConstants.java
index 69fb8c10dc..c815df9730 100644
--- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/common/EventMeshConstants.java
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/common/EventMeshConstants.java
@@ -69,33 +69,33 @@ public class EventMeshConstants {
public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS";
- public static final String BORN_TIMESTAMP = "BORN_TIME";
- public static final String STORE_TIMESTAMP = "STORE_TIME";
- public static final String LEAVE_TIMESTAMP = "LEAVE_TIME";
- public static final String ARRIVE_TIMESTAMP = "ARRIVE_TIME";
+ public static final String BORN_TIMESTAMP = "borntime";
+ public static final String STORE_TIMESTAMP = "storetime";
+ public static final String LEAVE_TIMESTAMP = "leavetime";
+ public static final String ARRIVE_TIMESTAMP = "arrivetime";
public static final String KEYS_UPPERCASE = "KEYS";
public static final String KEYS_LOWERCASE = "keys";
public static final String RR_REQUEST_UNIQ_ID = "RR_REQUEST_UNIQ_ID";
- public static final String TTL = "TTL";
+ public static final String TTL = "ttl";
- public static final String TAG = "TAG";
+ public static final String TAG = "tag";
- public static final String MANAGE_SUBSYSTEM = "subSystem";
+ public static final String MANAGE_SUBSYSTEM = "subsystem";
public static final String MANAGE_IP = "ip";
public static final String MANAGE_PORT = "port";
- public static final String MANAGE_DEST_IP = "destEventMeshIp";
- public static final String MANAGE_DEST_PORT = "destEventMeshPort";
+ public static final String MANAGE_DEST_IP = "desteventmeship";
+ public static final String MANAGE_DEST_PORT = "desteventmeshport";
public static final String MANAGE_PATH = "path";
public static final String MANAGE_GROUP = "group";
public static final String MANAGE_PURPOSE = "purpose";
public static final String MANAGE_TOPIC = "topic";
- public static final String EventMesh_SEND_BACK_TIMES = "EventMeshSendBackTimes";
+ public static final String EventMesh_SEND_BACK_TIMES = "eventmeshsendbacktimes";
- public static final String EventMesh_SEND_BACK_IP = "EventMeshSendBackIp";
+ public static final String EventMesh_SEND_BACK_IP = "eventmeshsendbackip";
- public static final String EventMesh_REGISTRY_ADDR_KEY = "EventMeshRegistryAddr";
+ public static final String EventMesh_REGISTRY_ADDR_KEY = "eventmeshregistryaddr";
public static int DEFAULT_TIME_OUT_MILLS = 5 * 1000;
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfig.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfig.java
index aad0b49a53..f03a38a4a9 100644
--- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfig.java
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfig.java
@@ -17,11 +17,10 @@
package org.apache.eventmesh.connector.rocketmq.config;
-import io.openmessaging.api.OMSBuiltinKeys;
import org.apache.eventmesh.connector.rocketmq.domain.NonStandardKeys;
-public class ClientConfig implements OMSBuiltinKeys, NonStandardKeys {
+public class ClientConfig implements NonStandardKeys {
private String driverImpl;
private String accessPoints;
private String namespace;
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfiguration.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfiguration.java
index f1b9335bbe..20e6d87b61 100644
--- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfiguration.java
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ClientConfiguration.java
@@ -17,107 +17,140 @@
package org.apache.eventmesh.connector.rocketmq.config;
-import com.google.common.base.Preconditions;
-
import org.apache.commons.lang3.StringUtils;
+import com.google.common.base.Preconditions;
+
public class ClientConfiguration {
- public String namesrvAddr = "";
- public String clientUserName = "username";
- public String clientPass = "password";
- public Integer consumeThreadMin = 2;
- public Integer consumeThreadMax = 2;
- public Integer consumeQueueSize = 10000;
- public Integer pullBatchSize = 32;
- public Integer ackWindow = 1000;
- public Integer pubWindow = 100;
- public long consumeTimeout = 0L;
- public Integer pollNameServerInterval = 10 * 1000;
+ public String namesrvAddr = "";
+ public String clientUserName = "username";
+ public String clientPass = "password";
+ public Integer consumeThreadMin = 2;
+ public Integer consumeThreadMax = 2;
+ public Integer consumeQueueSize = 10000;
+ public Integer pullBatchSize = 32;
+ public Integer ackWindow = 1000;
+ public Integer pubWindow = 100;
+ public long consumeTimeout = 0L;
+ public Integer pollNameServerInterval = 10 * 1000;
public Integer heartbeatBrokerInterval = 30 * 1000;
- public Integer rebalanceInterval = 20 * 1000;
-
- protected ConfigurationWrapper configurationWrapper;
-
- public ClientConfiguration(ConfigurationWrapper configurationWrapper) {
- this.configurationWrapper = configurationWrapper;
- }
+ public Integer rebalanceInterval = 20 * 1000;
+ public String clusterName = "";
+ public String accessKey = "";
+ public String secretKey = "";
public void init() {
- String clientUserNameStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_USERNAME);
+ String clientUserNameStr = ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_USERNAME);
if (StringUtils.isNotBlank(clientUserNameStr)) {
clientUserName = StringUtils.trim(clientUserNameStr);
}
- String clientPassStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_PASSWORD);
+ String clientPassStr = ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_PASSWORD);
if (StringUtils.isNotBlank(clientPassStr)) {
clientPass = StringUtils.trim(clientPassStr);
}
- String namesrvAddrStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_NAMESRV_ADDR);
- Preconditions.checkState(StringUtils.isNotEmpty(namesrvAddrStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_NAMESRV_ADDR));
+ String namesrvAddrStr = ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_NAMESRV_ADDR);
+ Preconditions.checkState(StringUtils.isNotEmpty(namesrvAddrStr),
+ String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_NAMESRV_ADDR));
namesrvAddr = StringUtils.trim(namesrvAddrStr);
- String consumeThreadPoolMinStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MIN);
+ String consumeThreadPoolMinStr =
+ ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MIN);
if (StringUtils.isNotEmpty(consumeThreadPoolMinStr)) {
- Preconditions.checkState(StringUtils.isNumeric(consumeThreadPoolMinStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MIN));
+ Preconditions.checkState(StringUtils.isNumeric(consumeThreadPoolMinStr),
+ String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MIN));
consumeThreadMin = Integer.valueOf(consumeThreadPoolMinStr);
}
- String consumeThreadPoolMaxStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MAX);
+ String consumeThreadPoolMaxStr =
+ ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MAX);
if (StringUtils.isNotEmpty(consumeThreadPoolMaxStr)) {
- Preconditions.checkState(StringUtils.isNumeric(consumeThreadPoolMaxStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MAX));
+ Preconditions.checkState(StringUtils.isNumeric(consumeThreadPoolMaxStr),
+ String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MAX));
consumeThreadMax = Integer.valueOf(consumeThreadPoolMaxStr);
}
- String consumerThreadPoolQueueSizeStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_QUEUESIZE);
+ String consumerThreadPoolQueueSizeStr =
+ ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_QUEUESIZE);
if (StringUtils.isNotEmpty(consumerThreadPoolQueueSizeStr)) {
- Preconditions.checkState(StringUtils.isNumeric(consumerThreadPoolQueueSizeStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_QUEUESIZE));
+ Preconditions.checkState(StringUtils.isNumeric(consumerThreadPoolQueueSizeStr),
+ String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_QUEUESIZE));
consumeQueueSize = Integer.valueOf(consumerThreadPoolQueueSizeStr);
}
- String clientAckWindowStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_ACK_WINDOW);
+ String clientAckWindowStr = ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_ACK_WINDOW);
if (StringUtils.isNotEmpty(clientAckWindowStr)) {
- Preconditions.checkState(StringUtils.isNumeric(clientAckWindowStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_ACK_WINDOW));
+ Preconditions.checkState(StringUtils.isNumeric(clientAckWindowStr),
+ String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_ACK_WINDOW));
ackWindow = Integer.valueOf(clientAckWindowStr);
}
- String clientPubWindowStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_PUB_WINDOW);
+ String clientPubWindowStr = ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_PUB_WINDOW);
if (StringUtils.isNotEmpty(clientPubWindowStr)) {
- Preconditions.checkState(StringUtils.isNumeric(clientPubWindowStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_PUB_WINDOW));
+ Preconditions.checkState(StringUtils.isNumeric(clientPubWindowStr),
+ String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_PUB_WINDOW));
pubWindow = Integer.valueOf(clientPubWindowStr);
}
- String consumeTimeoutStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_CONSUME_TIMEOUT);
+ String consumeTimeoutStr =
+ ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_CONSUME_TIMEOUT);
if (StringUtils.isNotBlank(consumeTimeoutStr)) {
- Preconditions.checkState(StringUtils.isNumeric(consumeTimeoutStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_CONSUME_TIMEOUT));
+ Preconditions.checkState(StringUtils.isNumeric(consumeTimeoutStr),
+ String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_CONSUME_TIMEOUT));
consumeTimeout = Long.valueOf(consumeTimeoutStr);
}
- String clientPullBatchSizeStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_PULL_BATCHSIZE);
+ String clientPullBatchSizeStr =
+ ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_PULL_BATCHSIZE);
if (StringUtils.isNotEmpty(clientPullBatchSizeStr)) {
- Preconditions.checkState(StringUtils.isNumeric(clientPullBatchSizeStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_PULL_BATCHSIZE));
+ Preconditions.checkState(StringUtils.isNumeric(clientPullBatchSizeStr),
+ String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_PULL_BATCHSIZE));
pullBatchSize = Integer.valueOf(clientPullBatchSizeStr);
}
- String clientPollNamesrvIntervalStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_POLL_NAMESRV_INTERVAL);
+ String clientPollNamesrvIntervalStr =
+ ConfigurationWrapper.getProp(
+ ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_POLL_NAMESRV_INTERVAL);
if (StringUtils.isNotEmpty(clientPollNamesrvIntervalStr)) {
- Preconditions.checkState(StringUtils.isNumeric(clientPollNamesrvIntervalStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_POLL_NAMESRV_INTERVAL));
+ Preconditions.checkState(StringUtils.isNumeric(clientPollNamesrvIntervalStr),
+ String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_POLL_NAMESRV_INTERVAL));
pollNameServerInterval = Integer.valueOf(clientPollNamesrvIntervalStr);
}
- String clientHeartbeatBrokerIntervalStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_HEARTBEAT_BROKER_INTERVAL);
+ String clientHeartbeatBrokerIntervalStr =
+ ConfigurationWrapper.getProp(
+ ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_HEARTBEAT_BROKER_INTERVAL);
if (StringUtils.isNotEmpty(clientHeartbeatBrokerIntervalStr)) {
- Preconditions.checkState(StringUtils.isNumeric(clientHeartbeatBrokerIntervalStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_HEARTBEAT_BROKER_INTERVAL));
+ Preconditions.checkState(StringUtils.isNumeric(clientHeartbeatBrokerIntervalStr),
+ String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_HEARTBEAT_BROKER_INTERVAL));
heartbeatBrokerInterval = Integer.valueOf(clientHeartbeatBrokerIntervalStr);
}
- String clientRebalanceIntervalIntervalStr = configurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_REBALANCE_INTERVAL);
+ String clientRebalanceIntervalIntervalStr =
+ ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_REBALANCE_INTERVAL);
if (StringUtils.isNotEmpty(clientRebalanceIntervalIntervalStr)) {
- Preconditions.checkState(StringUtils.isNumeric(clientRebalanceIntervalIntervalStr), String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_REBALANCE_INTERVAL));
+ Preconditions.checkState(StringUtils.isNumeric(clientRebalanceIntervalIntervalStr),
+ String.format("%s error", ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLIENT_REBALANCE_INTERVAL));
rebalanceInterval = Integer.valueOf(clientRebalanceIntervalIntervalStr);
}
+
+ String cluster = ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_CLUSTER);
+ if (StringUtils.isNotBlank(cluster)) {
+ clusterName = cluster;
+ }
+
+ String ak = ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_ACCESS_KEY);
+ if (StringUtils.isNotBlank(ak)) {
+ accessKey = ak;
+ }
+
+ String sk = ConfigurationWrapper.getProp(ConfKeys.KEYS_EVENTMESH_ROCKETMQ_SECRET_KEY);
+ if (StringUtils.isNotBlank(sk)) {
+ secretKey = sk;
+ }
}
static class ConfKeys {
@@ -128,25 +161,41 @@ static class ConfKeys {
public static String KEYS_EVENTMESH_ROCKETMQ_PASSWORD = "eventMesh.server.rocketmq.password";
- public static String KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MIN = "eventMesh.server.rocketmq.client.consumeThreadMin";
+ public static String KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MIN =
+ "eventMesh.server.rocketmq.client.consumeThreadMin";
- public static String KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MAX = "eventMesh.server.rocketmq.client.consumeThreadMax";
+ public static String KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_MAX =
+ "eventMesh.server.rocketmq.client.consumeThreadMax";
- public static String KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_QUEUESIZE = "eventMesh.server.rocketmq.client.consumeThreadPoolQueueSize";
+ public static String KEYS_EVENTMESH_ROCKETMQ_CONSUME_THREADPOOL_QUEUESIZE =
+ "eventMesh.server.rocketmq.client.consumeThreadPoolQueueSize";
public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_ACK_WINDOW = "eventMesh.server.rocketmq.client.ackwindow";
public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_PUB_WINDOW = "eventMesh.server.rocketmq.client.pubwindow";
- public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_CONSUME_TIMEOUT = "eventMesh.server.rocketmq.client.comsumeTimeoutInMin";
+ public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_CONSUME_TIMEOUT =
+ "eventMesh.server.rocketmq.client.comsumeTimeoutInMin";
+
+ public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_PULL_BATCHSIZE =
+ "eventMesh.server.rocketmq.client.pullBatchSize";
+
+ public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_POLL_NAMESRV_INTERVAL =
+ "eventMesh.server.rocketmq.client.pollNameServerInterval";
+
+ public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_HEARTBEAT_BROKER_INTERVAL =
+ "eventMesh.server.rocketmq.client.heartbeatBrokerInterval";
- public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_PULL_BATCHSIZE = "eventMesh.server.rocketmq.client.pullBatchSize";
+ public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_REBALANCE_INTERVAL =
+ "eventMesh.server.rocketmq.client.rebalanceInterval";
- public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_POLL_NAMESRV_INTERVAL = "eventMesh.server.rocketmq.client.pollNameServerInterval";
+ public static String KEYS_EVENTMESH_ROCKETMQ_CLUSTER = "eventMesh.server.rocketmq.cluster";
- public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_HEARTBEAT_BROKER_INTERVAL = "eventMesh.server.rocketmq.client.heartbeatBrokerInterval";
+ public static String KEYS_EVENTMESH_ROCKETMQ_ACCESS_KEY =
+ "eventMesh.server.rocketmq.accessKey";
- public static String KEYS_EVENTMESH_ROCKETMQ_CLIENT_REBALANCE_INTERVAL = "eventMesh.server.rocketmq.client.rebalanceInterval";
+ public static String KEYS_EVENTMESH_ROCKETMQ_SECRET_KEY =
+ "eventMesh.server.rocketmq.secretKey";
}
}
\ No newline at end of file
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ConfigurationWrapper.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ConfigurationWrapper.java
index 9334b5fc98..9ff3861ad6 100644
--- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ConfigurationWrapper.java
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/config/ConfigurationWrapper.java
@@ -17,60 +17,48 @@
package org.apache.eventmesh.connector.rocketmq.config;
+import org.apache.eventmesh.connector.rocketmq.common.EventMeshConstants;
+
+import org.apache.commons.lang3.StringUtils;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
+import java.net.URL;
import java.util.Properties;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.eventmesh.common.ThreadPoolFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import lombok.experimental.UtilityClass;
+import lombok.extern.slf4j.Slf4j;
+@Slf4j
+@UtilityClass
public class ConfigurationWrapper {
- public Logger logger = LoggerFactory.getLogger(this.getClass());
-
- private String file;
-
- private Properties properties = new Properties();
-
- private boolean reload = true;
-
- private ScheduledExecutorService configLoader = ThreadPoolFactory.createSingleScheduledExecutor("eventMesh-configloader-");
+ private static final Properties properties = new Properties();
- public ConfigurationWrapper(String file, boolean reload) {
- this.file = file;
- this.reload = reload;
- init();
- }
-
- private void init() {
- load();
- if (this.reload) {
- configLoader.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- load();
- }
- }, 30 * 1000, 30 * 1000, TimeUnit.MILLISECONDS);
- }
- }
-
- private void load() {
+ static {
+ String configFile = getConfigFilePath();
+ log.info("loading config: {}", configFile);
try {
- logger.info("loading config: {}", file);
- properties.load(new BufferedReader(new FileReader(
- new File(file))));
+ properties.load(new BufferedReader(new FileReader(configFile)));
} catch (IOException e) {
- logger.error("loading properties [{}] error", file, e);
+ throw new IllegalArgumentException(
+ String.format("Cannot load RocketMQ configuration file from :%s", configFile));
}
}
public String getProp(String key) {
return StringUtils.isEmpty(key) ? null : properties.getProperty(key, null);
}
+
+ private static String getConfigFilePath() {
+ // get from classpath
+ URL resource = ConfigurationWrapper.class.getClassLoader().getResource(EventMeshConstants.EVENTMESH_CONF_FILE);
+ if (resource != null && new File(resource.getPath()).exists()) {
+ return resource.getPath();
+ }
+ // get from config home
+ return EventMeshConstants.EVENTMESH_CONF_HOME + File.separator + EventMeshConstants.EVENTMESH_CONF_FILE;
+ }
}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/PushConsumerImpl.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/PushConsumerImpl.java
index 47565e3b03..e7e5ae8e7e 100644
--- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/PushConsumerImpl.java
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/PushConsumerImpl.java
@@ -17,21 +17,14 @@
package org.apache.eventmesh.connector.rocketmq.consumer;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicBoolean;
-import io.openmessaging.api.AsyncGenericMessageListener;
-import io.openmessaging.api.AsyncMessageListener;
-import io.openmessaging.api.Consumer;
-import io.openmessaging.api.GenericMessageListener;
-import io.openmessaging.api.Message;
-import io.openmessaging.api.MessageListener;
-import io.openmessaging.api.MessageSelector;
-import io.openmessaging.api.exception.OMSRuntimeException;
+import org.apache.eventmesh.api.AbstractContext;
+import org.apache.eventmesh.api.AsyncConsumeContext;
+import org.apache.eventmesh.api.EventListener;
import org.apache.eventmesh.api.EventMeshAction;
import org.apache.eventmesh.api.EventMeshAsyncConsumeContext;
+import org.apache.eventmesh.api.exception.ConnectorRuntimeException;
import org.apache.eventmesh.common.Constants;
+import org.apache.eventmesh.connector.rocketmq.cloudevent.RocketMQMessageFactory;
import org.apache.eventmesh.connector.rocketmq.common.EventMeshConstants;
import org.apache.eventmesh.connector.rocketmq.config.ClientConfig;
import org.apache.eventmesh.connector.rocketmq.domain.NonStandardKeys;
@@ -40,17 +33,34 @@
import org.apache.eventmesh.connector.rocketmq.patch.EventMeshMessageListenerConcurrently;
import org.apache.eventmesh.connector.rocketmq.utils.BeanUtils;
import org.apache.eventmesh.connector.rocketmq.utils.OMSUtil;
+import org.apache.eventmesh.connector.rocketmq.utils.CloudEventUtils;
+
+import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.impl.consumer.ConsumeMessageConcurrentlyService;
+import org.apache.rocketmq.client.impl.consumer.ConsumeMessageService;
+import org.apache.rocketmq.client.utils.MessageUtil;
+import org.apache.rocketmq.common.message.MessageConst;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
import org.apache.rocketmq.remoting.protocol.LanguageCode;
-public class PushConsumerImpl implements Consumer {
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import io.cloudevents.CloudEvent;
+import io.cloudevents.core.builder.CloudEventBuilder;
+
+public class PushConsumerImpl {
private final DefaultMQPushConsumer rocketmqPushConsumer;
private final Properties properties;
private AtomicBoolean started = new AtomicBoolean(false);
- private final Map subscribeTable = new ConcurrentHashMap<>();
+ private final Map subscribeTable = new ConcurrentHashMap<>();
private final ClientConfig clientConfig;
public PushConsumerImpl(final Properties properties) {
@@ -58,25 +68,23 @@ public PushConsumerImpl(final Properties properties) {
this.properties = properties;
this.clientConfig = BeanUtils.populate(properties, ClientConfig.class);
-// if ("true".equalsIgnoreCase(System.getenv("OMS_RMQ_DIRECT_NAME_SRV"))) {
-//
-//
-// }
String accessPoints = clientConfig.getAccessPoints();
if (accessPoints == null || accessPoints.isEmpty()) {
- throw new OMSRuntimeException(-1, "OMS AccessPoints is null or empty.");
+ throw new ConnectorRuntimeException("OMS AccessPoints is null or empty.");
}
this.rocketmqPushConsumer.setNamesrvAddr(accessPoints.replace(',', ';'));
String consumerGroup = clientConfig.getConsumerId();
if (null == consumerGroup || consumerGroup.isEmpty()) {
- throw new OMSRuntimeException(-1, "Consumer Group is necessary for RocketMQ, please set it.");
+ throw new ConnectorRuntimeException(
+ "Consumer Group is necessary for RocketMQ, please set it.");
}
this.rocketmqPushConsumer.setConsumerGroup(consumerGroup);
this.rocketmqPushConsumer.setMaxReconsumeTimes(clientConfig.getRmqMaxRedeliveryTimes());
this.rocketmqPushConsumer.setConsumeTimeout(clientConfig.getRmqMessageConsumeTimeout());
this.rocketmqPushConsumer.setConsumeThreadMax(clientConfig.getRmqMaxConsumeThreadNums());
this.rocketmqPushConsumer.setConsumeThreadMin(clientConfig.getRmqMinConsumeThreadNums());
- this.rocketmqPushConsumer.setMessageModel(MessageModel.valueOf(clientConfig.getMessageModel()));
+ this.rocketmqPushConsumer.setMessageModel(
+ MessageModel.valueOf(clientConfig.getMessageModel()));
String consumerId = OMSUtil.buildInstanceName();
//this.rocketmqPushConsumer.setInstanceName(consumerId);
@@ -85,109 +93,9 @@ public PushConsumerImpl(final Properties properties) {
this.rocketmqPushConsumer.setLanguage(LanguageCode.OMS);
if (clientConfig.getMessageModel().equalsIgnoreCase(MessageModel.BROADCASTING.name())) {
- rocketmqPushConsumer.registerMessageListener(new EventMeshMessageListenerConcurrently() {
-
- @Override
- public EventMeshConsumeConcurrentlyStatus handleMessage(MessageExt msg, EventMeshConsumeConcurrentlyContext context) {
- if (msg == null) {
- return EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS;
- }
-
-
-// if (!EventMeshUtil.isValidRMBTopic(msg.getTopic())) {
-// return EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS;
-// }
-
- msg.putUserProperty(Constants.PROPERTY_MESSAGE_BORN_TIMESTAMP, String.valueOf(msg.getBornTimestamp()));
- msg.putUserProperty(Constants.PROPERTY_MESSAGE_STORE_TIMESTAMP, String.valueOf(msg.getStoreTimestamp()));
-
- Message omsMsg = OMSUtil.msgConvert(msg);
-
- AsyncMessageListener listener = PushConsumerImpl.this.subscribeTable.get(msg.getTopic());
-
- if (listener == null) {
- throw new OMSRuntimeException(-1,
- String.format("The topic/queue %s isn't attached to this consumer", msg.getTopic()));
- }
-
- final Properties contextProperties = new Properties();
- contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, EventMeshConsumeConcurrentlyStatus.RECONSUME_LATER.name());
- EventMeshAsyncConsumeContext omsContext = new EventMeshAsyncConsumeContext() {
- @Override
- public void commit(EventMeshAction action) {
- switch (action){
- case CommitMessage:
- contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS.name());
- break;
- case ReconsumeLater:
- contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, EventMeshConsumeConcurrentlyStatus.RECONSUME_LATER.name());
- break;
- case ManualAck:
- contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, EventMeshConsumeConcurrentlyStatus.CONSUME_FINISH.name());
- break;
- default:
- break;
- }
- }
- };
- omsContext.setAbstractContext(context);
- listener.consume(omsMsg, omsContext);
-
- return EventMeshConsumeConcurrentlyStatus.valueOf(contextProperties.getProperty(NonStandardKeys.MESSAGE_CONSUME_STATUS));
- }
- });
+ rocketmqPushConsumer.registerMessageListener(new BroadCastingMessageListener());
} else {
- rocketmqPushConsumer.registerMessageListener(new EventMeshMessageListenerConcurrently() {
-
- @Override
- public EventMeshConsumeConcurrentlyStatus handleMessage(MessageExt msg, EventMeshConsumeConcurrentlyContext context) {
- if (msg == null) {
- return EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS;
- }
-// if (!EventMeshUtil.isValidRMBTopic(msg.getTopic())) {
-// return EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS;
-// }
-
- msg.putUserProperty(Constants.PROPERTY_MESSAGE_BORN_TIMESTAMP, String.valueOf(msg.getBornTimestamp()));
- msg.putUserProperty(EventMeshConstants.STORE_TIMESTAMP, String.valueOf(msg.getStoreTimestamp()));
-
- Message omsMsg = OMSUtil.msgConvert(msg);
-
- AsyncMessageListener listener = PushConsumerImpl.this.subscribeTable.get(msg.getTopic());
-
- if (listener == null) {
- throw new OMSRuntimeException(-1,
- String.format("The topic/queue %s isn't attached to this consumer", msg.getTopic()));
- }
-
- final Properties contextProperties = new Properties();
-
- contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, EventMeshConsumeConcurrentlyStatus.RECONSUME_LATER.name());
-
- EventMeshAsyncConsumeContext omsContext = new EventMeshAsyncConsumeContext() {
- @Override
- public void commit(EventMeshAction action) {
- switch (action) {
- case CommitMessage:
- contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS.name());
- break;
- case ReconsumeLater:
- contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, EventMeshConsumeConcurrentlyStatus.RECONSUME_LATER.name());
- break;
- case ManualAck:
- contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, EventMeshConsumeConcurrentlyStatus.CONSUME_FINISH.name());
- break;
- default:
- break;
- }
- }
- };
- omsContext.setAbstractContext(context);
- listener.consume(omsMsg, omsContext);
-
- return EventMeshConsumeConcurrentlyStatus.valueOf(contextProperties.getProperty(NonStandardKeys.MESSAGE_CONSUME_STATUS));
- }
- });
+ rocketmqPushConsumer.registerMessageListener(new ClusteringMessageListener());
}
}
@@ -195,30 +103,30 @@ public Properties attributes() {
return properties;
}
- @Override
+
public void start() {
if (this.started.compareAndSet(false, true)) {
try {
this.rocketmqPushConsumer.start();
} catch (Exception e) {
- throw new OMSRuntimeException(e.getMessage());
+ throw new ConnectorRuntimeException(e.getMessage());
}
}
}
- @Override
+
public synchronized void shutdown() {
if (this.started.compareAndSet(true, false)) {
this.rocketmqPushConsumer.shutdown();
}
}
- @Override
+
public boolean isStarted() {
return this.started.get();
}
- @Override
+
public boolean isClosed() {
return !this.isStarted();
}
@@ -227,109 +135,182 @@ public DefaultMQPushConsumer getRocketmqPushConsumer() {
return rocketmqPushConsumer;
}
-// class MessageListenerImpl implements MessageListenerConcurrently {
-//
-// @Override
-// public ConsumeConcurrentlyStatus consumeMessage(List rmqMsgList,
-// ConsumeConcurrentlyContext contextRMQ) {
-// MessageExt rmqMsg = rmqMsgList.get(0);
-// BytesMessage omsMsg = OMSUtil.msgConvert(rmqMsg);
-//
-// MessageListener listener = PushConsumerImpl.this.subscribeTable.get(rmqMsg.getTopic());
-//
-// if (listener == null) {
-// throw new OMSRuntimeException("-1",
-// String.format("The topic/queue %s isn't attached to this consumer", rmqMsg.getTopic()));
-// }
-//
-// final KeyValue contextProperties = OMS.newKeyValue();
-// final CountDownLatch sync = new CountDownLatch(1);
-//
-// contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS, ConsumeConcurrentlyStatus.RECONSUME_LATER.name());
-//
-// MessageListener.Context context = new MessageListener.Context() {
-// @Override
-// public KeyValue attributes() {
-// return contextProperties;
-// }
-//
-// @Override
-// public void ack() {
-// sync.countDown();
-// contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS,
-// ConsumeConcurrentlyStatus.CONSUME_SUCCESS.name());
-// }
-// };
-// long begin = System.currentTimeMillis();
-// listener.onReceived(omsMsg, context);
-// long costs = System.currentTimeMillis() - begin;
-// long timeoutMills = clientConfig.getRmqMessageConsumeTimeout() * 60 * 1000;
-// try {
-// sync.await(Math.max(0, timeoutMills - costs), TimeUnit.MILLISECONDS);
-// } catch (InterruptedException ignore) {
-// }
-//
-// return ConsumeConcurrentlyStatus.valueOf(contextProperties.getString(NonStandardKeys.MESSAGE_CONSUME_STATUS));
-// }
-// }
-
- @Override
- public void subscribe(String topic, String subExpression, MessageListener listener) {
+ public void subscribe(String topic, String subExpression, EventListener listener) {
+ this.subscribeTable.put(topic, listener);
+ try {
+ this.rocketmqPushConsumer.subscribe(topic, subExpression);
+ } catch (MQClientException e) {
+ throw new ConnectorRuntimeException(String.format("RocketMQ push consumer can't attach to %s.", topic));
+ }
}
- @Override
- public void subscribe(String topic, MessageSelector selector, MessageListener listener) {
+ public void unsubscribe(String topic) {
+ this.subscribeTable.remove(topic);
+ try {
+ this.rocketmqPushConsumer.unsubscribe(topic);
+ } catch (Exception e) {
+ throw new ConnectorRuntimeException(String.format("RocketMQ push consumer fails to unsubscribe topic: %s", topic));
+ }
}
- @Override
- public void subscribe(String topic, String subExpression, GenericMessageListener listener) {
-
+ public void updateOffset(List cloudEvents, AbstractContext context) {
+ ConsumeMessageService consumeMessageService = rocketmqPushConsumer
+ .getDefaultMQPushConsumerImpl().getConsumeMessageService();
+ List msgExtList = new ArrayList<>(cloudEvents.size());
+ for (CloudEvent msg : cloudEvents) {
+ msgExtList.add(CloudEventUtils.msgConvertExt(
+ RocketMQMessageFactory.createWriter(msg.getSubject()).writeBinary(msg)));
+ }
+ ((ConsumeMessageConcurrentlyService) consumeMessageService)
+ .updateOffset(msgExtList, (EventMeshConsumeConcurrentlyContext) context);
}
- @Override
- public void subscribe(String topic, MessageSelector selector, GenericMessageListener listener) {
- }
+ private class BroadCastingMessageListener extends EventMeshMessageListenerConcurrently {
- @Override
- public void subscribe(String topic, String subExpression, AsyncMessageListener listener) {
- this.subscribeTable.put(topic, listener);
- try {
- this.rocketmqPushConsumer.subscribe(topic, subExpression);
- } catch (MQClientException e) {
- throw new OMSRuntimeException(-1, String.format("RocketMQ push consumer can't attach to %s.", topic));
+ @Override
+ public EventMeshConsumeConcurrentlyStatus handleMessage(MessageExt msg,
+ EventMeshConsumeConcurrentlyContext context) {
+ if (msg == null) {
+ return EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ }
+
+ msg.putUserProperty(Constants.PROPERTY_MESSAGE_BORN_TIMESTAMP,
+ String.valueOf(msg.getBornTimestamp()));
+ msg.putUserProperty(Constants.PROPERTY_MESSAGE_STORE_TIMESTAMP,
+ String.valueOf(msg.getStoreTimestamp()));
+
+ //for rr request/reply
+ CloudEvent cloudEvent =
+ RocketMQMessageFactory.createReader(CloudEventUtils.msgConvert(msg)).toEvent();
+
+ CloudEventBuilder cloudEventBuilder = null;
+ for (String sysPropKey : MessageConst.STRING_HASH_SET) {
+ if (StringUtils.isNotEmpty(msg.getProperty(sysPropKey))) {
+ String prop = msg.getProperty(sysPropKey);
+ sysPropKey = sysPropKey.toLowerCase().replaceAll("_", Constants.MESSAGE_PROP_SEPARATOR);
+ cloudEventBuilder = CloudEventBuilder.from(cloudEvent).withExtension(sysPropKey, prop);
+ }
+ }
+ if (cloudEventBuilder != null) {
+ cloudEvent = cloudEventBuilder.build();
+ }
+
+ EventListener listener = PushConsumerImpl.this.subscribeTable.get(msg.getTopic());
+
+ if (listener == null) {
+ throw new ConnectorRuntimeException(String.format("The topic/queue %s isn't attached to this consumer",
+ msg.getTopic()));
+ }
+
+ final Properties contextProperties = new Properties();
+ contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS,
+ EventMeshConsumeConcurrentlyStatus.RECONSUME_LATER.name());
+ AsyncConsumeContext asyncConsumeContext = new AsyncConsumeContext() {
+ @Override
+ public void commit(EventMeshAction action) {
+ switch (action) {
+ case CommitMessage:
+ contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS,
+ EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS.name());
+ break;
+ case ReconsumeLater:
+ contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS,
+ EventMeshConsumeConcurrentlyStatus.RECONSUME_LATER.name());
+ break;
+ case ManualAck:
+ contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS,
+ EventMeshConsumeConcurrentlyStatus.CONSUME_FINISH.name());
+ break;
+ default:
+ break;
+ }
+ }
+ };
+
+ listener.consume(cloudEvent, asyncConsumeContext);
+
+ return EventMeshConsumeConcurrentlyStatus.valueOf(
+ contextProperties.getProperty(NonStandardKeys.MESSAGE_CONSUME_STATUS));
}
- }
- @Override
- public void subscribe(String topic, MessageSelector selector, AsyncMessageListener listener) {
}
- @Override
- public void subscribe(String topic, String subExpression, AsyncGenericMessageListener listener) {
+ private class ClusteringMessageListener extends EventMeshMessageListenerConcurrently {
- }
+ @Override
+ public EventMeshConsumeConcurrentlyStatus handleMessage(MessageExt msg,
+ EventMeshConsumeConcurrentlyContext context) {
+ if (msg == null) {
+ return EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ }
- @Override
- public void subscribe(String topic, MessageSelector selector, AsyncGenericMessageListener listener) {
+ msg.putUserProperty(Constants.PROPERTY_MESSAGE_BORN_TIMESTAMP,
+ String.valueOf(msg.getBornTimestamp()));
+ msg.putUserProperty(EventMeshConstants.STORE_TIMESTAMP,
+ String.valueOf(msg.getStoreTimestamp()));
- }
+ CloudEvent cloudEvent =
+ RocketMQMessageFactory.createReader(CloudEventUtils.msgConvert(msg)).toEvent();
- @Override
- public void unsubscribe(String topic) {
- this.subscribeTable.remove(topic);
- try {
- this.rocketmqPushConsumer.unsubscribe(topic);
- } catch (Exception e) {
- throw new OMSRuntimeException(-1, String.format("RocketMQ push consumer fails to unsubscribe topic: %s", topic));
+ CloudEventBuilder cloudEventBuilder = null;
+
+ for (String sysPropKey : MessageConst.STRING_HASH_SET) {
+ if (StringUtils.isNotEmpty(msg.getProperty(sysPropKey))) {
+ String prop = msg.getProperty(sysPropKey);
+ sysPropKey = sysPropKey.toLowerCase().replaceAll("_", Constants.MESSAGE_PROP_SEPARATOR);
+ cloudEventBuilder = CloudEventBuilder.from(cloudEvent).withExtension(sysPropKey, prop);
+ }
+ }
+ if (cloudEventBuilder != null) {
+ cloudEvent = cloudEventBuilder.build();
+ }
+
+ EventListener listener = PushConsumerImpl.this.subscribeTable.get(msg.getTopic());
+
+ if (listener == null) {
+ throw new ConnectorRuntimeException(String.format("The topic/queue %s isn't attached to this consumer",
+ msg.getTopic()));
+ }
+
+ final Properties contextProperties = new Properties();
+
+ contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS,
+ EventMeshConsumeConcurrentlyStatus.RECONSUME_LATER.name());
+
+ EventMeshAsyncConsumeContext eventMeshAsyncConsumeContext = new EventMeshAsyncConsumeContext() {
+ @Override
+ public void commit(EventMeshAction action) {
+ switch (action) {
+ case CommitMessage:
+ contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS,
+ EventMeshConsumeConcurrentlyStatus.CONSUME_SUCCESS.name());
+ break;
+ case ReconsumeLater:
+ contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS,
+ EventMeshConsumeConcurrentlyStatus.RECONSUME_LATER.name());
+ break;
+ case ManualAck:
+ contextProperties.put(NonStandardKeys.MESSAGE_CONSUME_STATUS,
+ EventMeshConsumeConcurrentlyStatus.CONSUME_FINISH.name());
+ break;
+ default:
+ break;
+ }
+ }
+ };
+
+ eventMeshAsyncConsumeContext.setAbstractContext(context);
+
+ listener.consume(cloudEvent, eventMeshAsyncConsumeContext);
+
+ return EventMeshConsumeConcurrentlyStatus.valueOf(
+ contextProperties.getProperty(NonStandardKeys.MESSAGE_CONSUME_STATUS));
}
}
- @Override
- public void updateCredential(Properties credentialProperties) {
- }
}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/RocketMQConsumerImpl.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/RocketMQConsumerImpl.java
index d103cea839..5e4d4d3c95 100644
--- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/RocketMQConsumerImpl.java
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/consumer/RocketMQConsumerImpl.java
@@ -18,39 +18,24 @@
package org.apache.eventmesh.connector.rocketmq.consumer;
import org.apache.eventmesh.api.AbstractContext;
-import org.apache.eventmesh.api.consumer.MeshMQPushConsumer;
-import org.apache.eventmesh.connector.rocketmq.MessagingAccessPointImpl;
+import org.apache.eventmesh.api.EventListener;
+import org.apache.eventmesh.api.consumer.Consumer;
import org.apache.eventmesh.connector.rocketmq.common.Constants;
-import org.apache.eventmesh.connector.rocketmq.common.EventMeshConstants;
import org.apache.eventmesh.connector.rocketmq.config.ClientConfiguration;
-import org.apache.eventmesh.connector.rocketmq.config.ConfigurationWrapper;
-import org.apache.eventmesh.connector.rocketmq.patch.EventMeshConsumeConcurrentlyContext;
-import org.apache.eventmesh.connector.rocketmq.utils.OMSUtil;
-import org.apache.rocketmq.client.impl.consumer.ConsumeMessageConcurrentlyService;
-import org.apache.rocketmq.client.impl.consumer.ConsumeMessageService;
-import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
-import java.io.File;
-import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import io.openmessaging.api.AsyncGenericMessageListener;
-import io.openmessaging.api.AsyncMessageListener;
-import io.openmessaging.api.GenericMessageListener;
-import io.openmessaging.api.Message;
-import io.openmessaging.api.MessageListener;
-import io.openmessaging.api.MessageSelector;
-import io.openmessaging.api.MessagingAccessPoint;
+import io.cloudevents.CloudEvent;
+import lombok.extern.slf4j.Slf4j;
-public class RocketMQConsumerImpl implements MeshMQPushConsumer {
-
- public Logger logger = LoggerFactory.getLogger(this.getClass());
+@Slf4j
+public class RocketMQConsumerImpl implements Consumer {
public Logger messageLogger = LoggerFactory.getLogger("message");
@@ -58,23 +43,19 @@ public class RocketMQConsumerImpl implements MeshMQPushConsumer {
@Override
public synchronized void init(Properties keyValue) throws Exception {
- ConfigurationWrapper configurationWrapper =
- new ConfigurationWrapper(getRocketMqConfigFile(), false);
- final ClientConfiguration clientConfiguration =
- new ClientConfiguration(configurationWrapper);
+ final ClientConfiguration clientConfiguration = new ClientConfiguration();
clientConfiguration.init();
boolean isBroadcast = Boolean.parseBoolean(keyValue.getProperty("isBroadcast"));
String consumerGroup = keyValue.getProperty("consumerGroup");
String instanceName = keyValue.getProperty("instanceName");
-
if (isBroadcast) {
consumerGroup = Constants.BROADCAST_PREFIX + consumerGroup;
}
- String omsNamesrv = clientConfiguration.namesrvAddr;
+ String namesrvAddr = clientConfiguration.namesrvAddr;
Properties properties = new Properties();
- properties.put("ACCESS_POINTS", omsNamesrv);
+ properties.put("ACCESS_POINTS", namesrvAddr);
properties.put("REGION", "namespace");
properties.put("instanceName", instanceName);
properties.put("CONSUMER_ID", consumerGroup);
@@ -83,12 +64,12 @@ public synchronized void init(Properties keyValue) throws Exception {
} else {
properties.put("MESSAGE_MODEL", MessageModel.CLUSTERING.name());
}
- MessagingAccessPoint messagingAccessPoint = new MessagingAccessPointImpl(properties);
- pushConsumer = (PushConsumerImpl) messagingAccessPoint.createConsumer(properties);
+
+ pushConsumer = new PushConsumerImpl(properties);
}
@Override
- public void subscribe(String topic, AsyncMessageListener listener) throws Exception {
+ public void subscribe(String topic, EventListener listener) throws Exception {
pushConsumer.subscribe(topic, "*", listener);
}
@@ -108,16 +89,8 @@ public synchronized void start() {
}
@Override
- public void updateOffset(List msgs, AbstractContext context) {
- ConsumeMessageService consumeMessageService =
- pushConsumer.getRocketmqPushConsumer().getDefaultMQPushConsumerImpl()
- .getConsumeMessageService();
- List msgExtList = new ArrayList<>(msgs.size());
- for (Message msg : msgs) {
- msgExtList.add(OMSUtil.msgConvertExt(msg));
- }
- ((ConsumeMessageConcurrentlyService) consumeMessageService)
- .updateOffset(msgExtList, (EventMeshConsumeConcurrentlyContext) context);
+ public void updateOffset(List cloudEvents, AbstractContext context) {
+ pushConsumer.updateOffset(cloudEvents, context);
}
@Override
@@ -134,65 +107,4 @@ public Properties attributes() {
return pushConsumer.attributes();
}
- @Override
- public void subscribe(String topic, String subExpression, MessageListener listener) {
- throw new UnsupportedOperationException("not supported yet");
- }
-
- @Override
- public void subscribe(String topic, MessageSelector selector, MessageListener listener) {
- throw new UnsupportedOperationException("not supported yet");
- }
-
- @Override
- public void subscribe(String topic, String subExpression,
- GenericMessageListener listener) {
- throw new UnsupportedOperationException("not supported yet");
- }
-
- @Override
- public void subscribe(String topic, MessageSelector selector,
- GenericMessageListener listener) {
- throw new UnsupportedOperationException("not supported yet");
- }
-
- @Override
- public void subscribe(String topic, String subExpression, AsyncMessageListener listener) {
- throw new UnsupportedOperationException("not supported yet");
- }
-
- @Override
- public void subscribe(String topic, MessageSelector selector, AsyncMessageListener listener) {
- throw new UnsupportedOperationException("not supported yet");
- }
-
- @Override
- public void subscribe(String topic, String subExpression,
- AsyncGenericMessageListener listener) {
- throw new UnsupportedOperationException("not supported yet");
- }
-
- @Override
- public void subscribe(String topic, MessageSelector selector,
- AsyncGenericMessageListener listener) {
- throw new UnsupportedOperationException("not supported yet");
- }
-
- @Override
- public void updateCredential(Properties credentialProperties) {
-
- }
-
- private String getRocketMqConfigFile() {
- // get from classpath
- String configFile = RocketMQConsumerImpl.class.getClassLoader()
- .getResource(EventMeshConstants.EVENTMESH_CONF_FILE).getPath();
- if (new File(configFile).exists()) {
- return configFile;
- }
- // get from config home
- configFile = EventMeshConstants.EVENTMESH_CONF_HOME + File.separator
- + EventMeshConstants.EVENTMESH_CONF_FILE;
- return configFile;
- }
}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/exception/RMQMessageFormatException.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/exception/RMQMessageFormatException.java
new file mode 100644
index 0000000000..703b7ea2bf
--- /dev/null
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/exception/RMQMessageFormatException.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.rocketmq.exception;
+
+import org.apache.eventmesh.api.exception.ConnectorRuntimeException;
+
+public class RMQMessageFormatException extends ConnectorRuntimeException {
+
+ public RMQMessageFormatException(String message) {
+ super(message);
+ }
+
+ public RMQMessageFormatException(Throwable throwable) {
+ super(throwable);
+ }
+
+ public RMQMessageFormatException(String message, Throwable throwable) {
+ super(message, throwable);
+ }
+}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/exception/RMQTimeoutException.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/exception/RMQTimeoutException.java
new file mode 100644
index 0000000000..c2a6b03410
--- /dev/null
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/exception/RMQTimeoutException.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.rocketmq.exception;
+
+import org.apache.eventmesh.api.exception.ConnectorRuntimeException;
+
+public class RMQTimeoutException extends ConnectorRuntimeException {
+
+ public RMQTimeoutException(String message) {
+ super(message);
+ }
+
+ public RMQTimeoutException(Throwable throwable) {
+ super(throwable);
+ }
+
+ public RMQTimeoutException(String message, Throwable throwable) {
+ super(message, throwable);
+ }
+}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/AbstractOMSProducer.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/AbstractProducer.java
similarity index 69%
rename from eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/AbstractOMSProducer.java
rename to eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/AbstractProducer.java
index 548077a4ec..3b0b7ce55d 100644
--- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/AbstractOMSProducer.java
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/AbstractProducer.java
@@ -20,13 +20,13 @@
import java.util.Properties;
import java.util.concurrent.atomic.AtomicBoolean;
-import io.openmessaging.api.exception.OMSMessageFormatException;
-import io.openmessaging.api.exception.OMSRuntimeException;
-import io.openmessaging.api.exception.OMSTimeOutException;
-
+import org.apache.eventmesh.api.exception.ConnectorRuntimeException;
import org.apache.eventmesh.connector.rocketmq.config.ClientConfig;
+import org.apache.eventmesh.connector.rocketmq.exception.RMQMessageFormatException;
+import org.apache.eventmesh.connector.rocketmq.exception.RMQTimeoutException;
import org.apache.eventmesh.connector.rocketmq.utils.BeanUtils;
import org.apache.eventmesh.connector.rocketmq.utils.OMSUtil;
+
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl;
@@ -38,7 +38,7 @@
import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
import org.apache.rocketmq.remoting.protocol.LanguageCode;
-public abstract class AbstractOMSProducer {
+public abstract class AbstractProducer {
final static InternalLogger log = ClientLogger.getLog();
final Properties properties;
@@ -48,14 +48,14 @@ public abstract class AbstractOMSProducer {
private final ClientConfig clientConfig;
private final String PRODUCER_ID = "PRODUCER_ID";
- AbstractOMSProducer(final Properties properties) {
+ AbstractProducer(final Properties properties) {
this.properties = properties;
this.rocketmqProducer = new DefaultMQProducer();
this.clientConfig = BeanUtils.populate(properties, ClientConfig.class);
String accessPoints = clientConfig.getAccessPoints();
if (accessPoints == null || accessPoints.isEmpty()) {
- throw new OMSRuntimeException(-1, "OMS AccessPoints is null or empty.");
+ throw new ConnectorRuntimeException("OMS AccessPoints is null or empty.");
}
this.rocketmqProducer.setNamesrvAddr(accessPoints.replace(',', ';'));
@@ -75,7 +75,7 @@ public synchronized void start() {
try {
this.rocketmqProducer.start();
} catch (MQClientException e) {
- throw new OMSRuntimeException("-1", e);
+ throw new ConnectorRuntimeException("-1", e);
}
}
this.started.set(true);
@@ -96,25 +96,30 @@ public boolean isClosed() {
return !this.isStarted();
}
- OMSRuntimeException checkProducerException(String topic, String msgId, Throwable e) {
+ ConnectorRuntimeException checkProducerException(String topic, String msgId, Throwable e) {
if (e instanceof MQClientException) {
if (e.getCause() != null) {
if (e.getCause() instanceof RemotingTimeoutException) {
- return new OMSTimeOutException(-1, String.format("Send message to broker timeout, %dms, Topic=%s, msgId=%s",
+ return new RMQTimeoutException(
+ String.format("Send message to broker timeout, %dms, Topic=%s, msgId=%s",
this.rocketmqProducer.getSendMsgTimeout(), topic, msgId), e);
- } else if (e.getCause() instanceof MQBrokerException || e.getCause() instanceof RemotingConnectException) {
+ } else if (e.getCause() instanceof MQBrokerException ||
+ e.getCause() instanceof RemotingConnectException) {
if (e.getCause() instanceof MQBrokerException) {
MQBrokerException brokerException = (MQBrokerException) e.getCause();
- return new OMSRuntimeException(-1, String.format("Received a broker exception, Topic=%s, msgId=%s, %s",
+ return new ConnectorRuntimeException(
+ String.format("Received a broker exception, Topic=%s, msgId=%s, %s",
topic, msgId, brokerException.getErrorMessage()), e);
}
if (e.getCause() instanceof RemotingConnectException) {
- RemotingConnectException connectException = (RemotingConnectException) e.getCause();
- return new OMSRuntimeException(-1,
- String.format("Network connection experiences failures. Topic=%s, msgId=%s, %s",
- topic, msgId, connectException.getMessage()),
- e);
+ RemotingConnectException connectException =
+ (RemotingConnectException) e.getCause();
+ return new ConnectorRuntimeException(
+ String.format(
+ "Network connection experiences failures. Topic=%s, msgId=%s, %s",
+ topic, msgId, connectException.getMessage()),
+ e);
}
}
}
@@ -122,25 +127,33 @@ OMSRuntimeException checkProducerException(String topic, String msgId, Throwable
else {
MQClientException clientException = (MQClientException) e;
if (-1 == clientException.getResponseCode()) {
- return new OMSRuntimeException(-1, String.format("Topic does not exist, Topic=%s, msgId=%s",
+ return new ConnectorRuntimeException(
+ String.format("Topic does not exist, Topic=%s, msgId=%s",
topic, msgId), e);
} else if (ResponseCode.MESSAGE_ILLEGAL == clientException.getResponseCode()) {
- return new OMSMessageFormatException(-1, String.format("A illegal message for RocketMQ, Topic=%s, msgId=%s",
+ return new RMQMessageFormatException(
+ String.format("A illegal message for RocketMQ, Topic=%s, msgId=%s",
topic, msgId), e);
}
}
}
- return new OMSRuntimeException(-1, "Send message to RocketMQ broker failed.", e);
+ return new ConnectorRuntimeException("Send message to RocketMQ broker failed.", e);
}
protected void checkProducerServiceState(DefaultMQProducerImpl producer) {
switch (producer.getServiceState()) {
case CREATE_JUST:
- throw new OMSRuntimeException(String.format("You do not have start the producer, %s", producer.getServiceState()));
+ throw new ConnectorRuntimeException(
+ String.format("You do not have start the producer, %s",
+ producer.getServiceState()));
case SHUTDOWN_ALREADY:
- throw new OMSRuntimeException(String.format("Your producer has been shut down, %s", producer.getServiceState()));
+ throw new ConnectorRuntimeException(
+ String.format("Your producer has been shut down, %s",
+ producer.getServiceState()));
case START_FAILED:
- throw new OMSRuntimeException(String.format("When you start your service throws an exception, %s", producer.getServiceState()));
+ throw new ConnectorRuntimeException(
+ String.format("When you start your service throws an exception, %s",
+ producer.getServiceState()));
case RUNNING:
default:
}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/ProducerImpl.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/ProducerImpl.java
index dbad619351..89c6b98b4f 100644
--- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/ProducerImpl.java
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/ProducerImpl.java
@@ -17,36 +17,37 @@
package org.apache.eventmesh.connector.rocketmq.producer;
-import org.apache.eventmesh.api.RRCallback;
-import org.apache.eventmesh.connector.rocketmq.utils.OMSUtil;
-
+import org.apache.eventmesh.api.RequestReplyCallback;
+import org.apache.eventmesh.api.SendCallback;
+import org.apache.eventmesh.api.SendResult;
+import org.apache.eventmesh.api.exception.ConnectorRuntimeException;
+import org.apache.eventmesh.api.exception.OnExceptionContext;
+import org.apache.eventmesh.common.Constants;
+import org.apache.eventmesh.connector.rocketmq.cloudevent.RocketMQMessageFactory;
+import org.apache.eventmesh.connector.rocketmq.utils.CloudEventUtils;
+
+import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.RequestCallback;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageAccessor;
import org.apache.rocketmq.common.message.MessageClientIDSetter;
-import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageConst;
import org.apache.rocketmq.remoting.exception.RemotingException;
import java.util.Properties;
-import java.util.concurrent.ExecutorService;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import io.openmessaging.api.Message;
-import io.openmessaging.api.MessageBuilder;
-import io.openmessaging.api.OnExceptionContext;
-import io.openmessaging.api.Producer;
-import io.openmessaging.api.SendCallback;
-import io.openmessaging.api.SendResult;
-import io.openmessaging.api.exception.OMSRuntimeException;
+import io.cloudevents.CloudEvent;
+import lombok.extern.slf4j.Slf4j;
-public class ProducerImpl extends AbstractOMSProducer implements Producer {
+@Slf4j
+@SuppressWarnings("deprecation")
+public class ProducerImpl extends AbstractProducer {
public static final int eventMeshServerAsyncAccumulationThreshold = 1000;
- private final Logger logger = LoggerFactory.getLogger(ProducerImpl.class);
-
public ProducerImpl(final Properties properties) {
super(properties);
}
@@ -60,84 +61,122 @@ public void setExtFields() {
super.getRocketmqProducer().setRetryTimesWhenSendAsyncFailed(0);
super.getRocketmqProducer().setPollNameServerInterval(60000);
- super.getRocketmqProducer().getDefaultMQProducerImpl().getmQClientFactory()
- .getNettyClientConfig()
+ super.getRocketmqProducer().getDefaultMQProducerImpl().getmQClientFactory().getNettyClientConfig()
.setClientAsyncSemaphoreValue(eventMeshServerAsyncAccumulationThreshold);
super.getRocketmqProducer().setCompressMsgBodyOverHowmuch(10);
}
- @Override
- public SendResult send(Message message) {
- this.checkProducerServiceState(rocketmqProducer.getDefaultMQProducerImpl());
- org.apache.rocketmq.common.message.Message msgRMQ = OMSUtil.msgConvert(message);
+ public SendResult send(CloudEvent cloudEvent) {
+ this.checkProducerServiceState(rocketmqProducer.getDefaultMQProducerImpl());
+ org.apache.rocketmq.common.message.Message msg =
+ RocketMQMessageFactory.createWriter(cloudEvent.getSubject()).writeBinary(cloudEvent);
+ msg = supplySysProp(msg, cloudEvent);
+ String messageId = null;
try {
- org.apache.rocketmq.client.producer.SendResult sendResultRmq =
- this.rocketmqProducer.send(msgRMQ);
- message.setMsgID(sendResultRmq.getMsgId());
+ org.apache.rocketmq.client.producer.SendResult sendResultRmq = this.rocketmqProducer.send(msg);
SendResult sendResult = new SendResult();
sendResult.setTopic(sendResultRmq.getMessageQueue().getTopic());
- sendResult.setMessageId(sendResultRmq.getMsgId());
+ messageId = sendResultRmq.getMsgId();
+ sendResult.setMessageId(messageId);
return sendResult;
} catch (Exception e) {
- log.error(String.format("Send message Exception, %s", message), e);
- throw this.checkProducerException(message.getTopic(), message.getMsgID(), e);
+ log.error(String.format("Send message Exception, %s", msg), e);
+ throw this.checkProducerException(msg.getTopic(), messageId, e);
}
}
- @Override
- public void sendOneway(Message message) {
- this.checkProducerServiceState(this.rocketmqProducer.getDefaultMQProducerImpl());
- org.apache.rocketmq.common.message.Message msgRMQ = OMSUtil.msgConvert(message);
+ public void sendOneway(CloudEvent cloudEvent) {
+ this.checkProducerServiceState(this.rocketmqProducer.getDefaultMQProducerImpl());
+ org.apache.rocketmq.common.message.Message msg =
+ RocketMQMessageFactory.createWriter(cloudEvent.getSubject()).writeBinary(cloudEvent);
+ msg = supplySysProp(msg, cloudEvent);
try {
- this.rocketmqProducer.sendOneway(msgRMQ);
- message.setMsgID(MessageClientIDSetter.getUniqID(msgRMQ));
+ this.rocketmqProducer.sendOneway(msg);
} catch (Exception e) {
- log.error(String.format("Send message oneway Exception, %s", message), e);
- throw this.checkProducerException(message.getTopic(), message.getMsgID(), e);
+ log.error(String.format("Send message oneway Exception, %s", msg), e);
+ throw this.checkProducerException(msg.getTopic(), MessageClientIDSetter.getUniqID(msg), e);
}
}
- @Override
- public void sendAsync(Message message, SendCallback sendCallback) {
- this.checkProducerServiceState(this.rocketmqProducer.getDefaultMQProducerImpl());
- org.apache.rocketmq.common.message.Message msgRMQ = OMSUtil.msgConvert(message);
+ public void sendAsync(CloudEvent cloudEvent, SendCallback sendCallback) {
+ this.checkProducerServiceState(this.rocketmqProducer.getDefaultMQProducerImpl());
+ org.apache.rocketmq.common.message.Message msg =
+ RocketMQMessageFactory.createWriter(cloudEvent.getSubject()).writeBinary(cloudEvent);
+ msg = supplySysProp(msg, cloudEvent);
try {
- this.rocketmqProducer.send(msgRMQ, this.sendCallbackConvert(message, sendCallback));
- message.setMsgID(MessageClientIDSetter.getUniqID(msgRMQ));
+ this.rocketmqProducer.send(msg, this.sendCallbackConvert(msg, sendCallback));
} catch (Exception e) {
- log.error(String.format("Send message async Exception, %s", message), e);
- throw this.checkProducerException(message.getTopic(), message.getMsgID(), e);
+ log.error(String.format("Send message async Exception, %s", msg), e);
+ throw this.checkProducerException(msg.getTopic(), MessageClientIDSetter.getUniqID(msg), e);
}
}
- public void request(Message message, RRCallback rrCallback, long timeout)
+ public void request(CloudEvent cloudEvent, RequestReplyCallback rrCallback, long timeout)
throws InterruptedException, RemotingException, MQClientException, MQBrokerException {
this.checkProducerServiceState(this.rocketmqProducer.getDefaultMQProducerImpl());
- org.apache.rocketmq.common.message.Message msgRMQ = OMSUtil.msgConvert(message);
- rocketmqProducer.request(msgRMQ, rrCallbackConvert(message, rrCallback), timeout);
+ org.apache.rocketmq.common.message.Message msg =
+ RocketMQMessageFactory.createWriter(cloudEvent.getSubject()).writeBinary(cloudEvent);
+
+ msg = supplySysProp(msg, cloudEvent);
+
+ rocketmqProducer.request(msg, rrCallbackConvert(msg, rrCallback), timeout);
+ }
+
+ public boolean reply(final CloudEvent cloudEvent, final SendCallback sendCallback) {
+ this.checkProducerServiceState(this.rocketmqProducer.getDefaultMQProducerImpl());
+ org.apache.rocketmq.common.message.Message msg =
+ RocketMQMessageFactory.createWriter(cloudEvent.getSubject()).writeBinary(cloudEvent);
+ MessageAccessor.putProperty(msg, MessageConst.PROPERTY_MESSAGE_TYPE, MixAll.REPLY_MESSAGE_FLAG);
+ msg = supplySysProp(msg, cloudEvent);
+
+ try {
+ this.rocketmqProducer.send(msg, this.sendCallbackConvert(msg, sendCallback));
+ } catch (Exception e) {
+ log.error(String.format("Send message async Exception, %s", msg), e);
+ throw this.checkProducerException(msg.getTopic(), MessageClientIDSetter.getUniqID(msg), e);
+ }
+ return true;
+
+ }
+
+ private Message supplySysProp(Message msg, CloudEvent cloudEvent) {
+ for (String sysPropKey : MessageConst.STRING_HASH_SET) {
+ String ceKey = sysPropKey.toLowerCase().replaceAll("_", Constants.MESSAGE_PROP_SEPARATOR);
+ if (cloudEvent.getExtension(ceKey) != null && StringUtils.isNotEmpty(cloudEvent.getExtension(ceKey).toString())) {
+ MessageAccessor.putProperty(msg, sysPropKey, cloudEvent.getExtension(ceKey).toString());
+ msg.getProperties().remove(ceKey);
+ }
+ }
+ return msg;
}
- private RequestCallback rrCallbackConvert(final Message message, final RRCallback rrCallback) {
+ private RequestCallback rrCallbackConvert(final Message message, final RequestReplyCallback rrCallback) {
return new RequestCallback() {
@Override
public void onSuccess(org.apache.rocketmq.common.message.Message message) {
- Message openMessage = OMSUtil.msgConvert((MessageExt) message);
- rrCallback.onSuccess(openMessage);
+ // clean the message property to lowercase
+ for (String sysPropKey : MessageConst.STRING_HASH_SET) {
+ if (StringUtils.isNotEmpty(message.getProperty(sysPropKey))) {
+ String prop = message.getProperty(sysPropKey);
+ String tmpPropKey = sysPropKey.toLowerCase().replaceAll("_", Constants.MESSAGE_PROP_SEPARATOR);
+ MessageAccessor.putProperty(message, tmpPropKey, prop);
+ message.getProperties().remove(sysPropKey);
+ }
+ }
+ CloudEvent event = RocketMQMessageFactory.createReader(message).toEvent();
+ rrCallback.onSuccess(event);
}
@Override
public void onException(Throwable e) {
String topic = message.getTopic();
- String msgId = message.getMsgID();
- OMSRuntimeException onsEx =
- ProducerImpl.this.checkProducerException(topic, msgId, e);
+ ConnectorRuntimeException onsEx = ProducerImpl.this.checkProducerException(topic, null, e);
OnExceptionContext context = new OnExceptionContext();
context.setTopic(topic);
- context.setMessageId(msgId);
context.setException(onsEx);
rrCallback.onException(e);
@@ -145,24 +184,21 @@ public void onException(Throwable e) {
};
}
- private org.apache.rocketmq.client.producer.SendCallback sendCallbackConvert(
- final Message message, final SendCallback sendCallback) {
+ private org.apache.rocketmq.client.producer.SendCallback sendCallbackConvert(final Message message,
+ final SendCallback sendCallback) {
org.apache.rocketmq.client.producer.SendCallback rmqSendCallback =
new org.apache.rocketmq.client.producer.SendCallback() {
@Override
public void onSuccess(org.apache.rocketmq.client.producer.SendResult sendResult) {
- sendCallback.onSuccess(OMSUtil.sendResultConvert(sendResult));
+ sendCallback.onSuccess(CloudEventUtils.convertSendResult(sendResult));
}
@Override
public void onException(Throwable e) {
String topic = message.getTopic();
- String msgId = message.getMsgID();
- OMSRuntimeException onsEx =
- ProducerImpl.this.checkProducerException(topic, msgId, e);
+ ConnectorRuntimeException onsEx = ProducerImpl.this.checkProducerException(topic, null, e);
OnExceptionContext context = new OnExceptionContext();
context.setTopic(topic);
- context.setMessageId(msgId);
context.setException(onsEx);
sendCallback.onException(context);
}
@@ -170,18 +206,4 @@ public void onException(Throwable e) {
return rmqSendCallback;
}
- @Override
- public void setCallbackExecutor(ExecutorService callbackExecutor) {
-// this.rocketmqProducer.setCallbackExecutor(callbackExecutor);
- }
-
- @Override
- public void updateCredential(Properties credentialProperties) {
-
- }
-
- @Override
- public MessageBuilder messageBuilder() {
- return null;
- }
}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/RocketMQProducerImpl.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/RocketMQProducerImpl.java
index 75e2360ba1..47ed2b1d83 100644
--- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/RocketMQProducerImpl.java
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/RocketMQProducerImpl.java
@@ -17,45 +17,31 @@
package org.apache.eventmesh.connector.rocketmq.producer;
-import java.io.File;
-import java.util.Properties;
-import java.util.concurrent.ExecutorService;
-
-import io.openmessaging.api.Message;
-import io.openmessaging.api.MessageBuilder;
-import io.openmessaging.api.MessagingAccessPoint;
-import io.openmessaging.api.OMS;
-import io.openmessaging.api.OMSBuiltinKeys;
-import io.openmessaging.api.SendCallback;
-import io.openmessaging.api.SendResult;
-
-import org.apache.eventmesh.api.RRCallback;
-import org.apache.eventmesh.api.producer.MeshMQProducer;
-import org.apache.eventmesh.connector.rocketmq.MessagingAccessPointImpl;
+import org.apache.eventmesh.api.RequestReplyCallback;
+import org.apache.eventmesh.api.SendCallback;
+import org.apache.eventmesh.api.SendResult;
+import org.apache.eventmesh.api.producer.Producer;
import org.apache.eventmesh.connector.rocketmq.common.EventMeshConstants;
import org.apache.eventmesh.connector.rocketmq.config.ClientConfiguration;
-import org.apache.eventmesh.connector.rocketmq.config.ConfigurationWrapper;
+
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
-import org.apache.rocketmq.common.MixAll;
-import org.apache.rocketmq.common.message.MessageConst;
import org.apache.rocketmq.remoting.exception.RemotingException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-public class RocketMQProducerImpl implements MeshMQProducer {
+import java.util.Properties;
+
+import io.cloudevents.CloudEvent;
+import lombok.extern.slf4j.Slf4j;
- public Logger logger = LoggerFactory.getLogger(this.getClass());
+@Slf4j
+@SuppressWarnings("deprecation")
+public class RocketMQProducerImpl implements Producer {
private ProducerImpl producer;
@Override
public synchronized void init(Properties keyValue) {
- ConfigurationWrapper configurationWrapper =
- new ConfigurationWrapper(EventMeshConstants.EVENTMESH_CONF_HOME
- + File.separator
- + EventMeshConstants.EVENTMESH_CONF_FILE, false);
- final ClientConfiguration clientConfiguration = new ClientConfiguration(configurationWrapper);
+ final ClientConfiguration clientConfiguration = new ClientConfiguration();
clientConfiguration.init();
String producerGroup = keyValue.getProperty("producerGroup");
@@ -67,8 +53,7 @@ public synchronized void init(Properties keyValue) {
properties.put("OPERATION_TIMEOUT", 3000);
properties.put("PRODUCER_ID", producerGroup);
- MessagingAccessPoint messagingAccessPoint = new MessagingAccessPointImpl(properties);
- producer = (ProducerImpl) messagingAccessPoint.createProducer(properties);
+ producer = new ProducerImpl(properties);
}
@@ -93,26 +78,26 @@ public synchronized void shutdown() {
}
@Override
- public void send(Message message, SendCallback sendCallback) throws Exception {
+ public void publish(CloudEvent message, SendCallback sendCallback) throws Exception {
producer.sendAsync(message, sendCallback);
}
@Override
- public void request(Message message, RRCallback rrCallback, long timeout)
- throws InterruptedException, RemotingException, MQClientException, MQBrokerException {
+ public void request(CloudEvent message, RequestReplyCallback rrCallback, long timeout)
+ throws InterruptedException, RemotingException, MQClientException, MQBrokerException {
producer.request(message, rrCallback, timeout);
}
@Override
- public boolean reply(final Message message, final SendCallback sendCallback) throws Exception {
- message.putSystemProperties(MessageConst.PROPERTY_MESSAGE_TYPE, MixAll.REPLY_MESSAGE_FLAG);
- producer.sendAsync(message, sendCallback);
+ public boolean reply(final CloudEvent message, final SendCallback sendCallback) throws Exception {
+ producer.reply(message, sendCallback);
return true;
}
@Override
public void checkTopicExist(String topic) throws Exception {
- this.producer.getRocketmqProducer().getDefaultMQProducerImpl().getmQClientFactory().getMQClientAPIImpl().getDefaultTopicRouteInfoFromNameServer(topic, EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS);
+ this.producer.getRocketmqProducer().getDefaultMQProducerImpl().getmQClientFactory().getMQClientAPIImpl()
+ .getDefaultTopicRouteInfoFromNameServer(topic, EventMeshConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS);
}
@Override
@@ -121,32 +106,19 @@ public void setExtFields() {
}
@Override
- public SendResult send(Message message) {
+ public SendResult publish(CloudEvent message) {
return producer.send(message);
}
@Override
- public void sendOneway(Message message) {
+ public void sendOneway(CloudEvent message) {
producer.sendOneway(message);
}
@Override
- public void sendAsync(Message message, SendCallback sendCallback) {
+ public void sendAsync(CloudEvent message, SendCallback sendCallback) {
producer.sendAsync(message, sendCallback);
}
- @Override
- public void setCallbackExecutor(ExecutorService callbackExecutor) {
- producer.setCallbackExecutor(callbackExecutor);
- }
-
- @Override
- public void updateCredential(Properties credentialProperties) {
- producer.updateCredential(credentialProperties);
- }
- @Override
- public MessageBuilder messageBuilder() {
- return null;
- }
}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/promise/DefaultPromise.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/promise/DefaultPromise.java
deleted file mode 100644
index cc30eb5ab0..0000000000
--- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/promise/DefaultPromise.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.eventmesh.connector.rocketmq.promise;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import io.openmessaging.api.Future;
-import io.openmessaging.api.FutureListener;
-import io.openmessaging.api.exception.OMSRuntimeException;
-
-import org.apache.rocketmq.logging.InternalLogger;
-import org.apache.rocketmq.logging.InternalLoggerFactory;
-
-public class DefaultPromise implements Future {
- private static final InternalLogger LOG = InternalLoggerFactory.getLogger(DefaultPromise.class);
- private final Object lock = new Object();
- private volatile FutureState state = FutureState.DOING;
- private V result = null;
- private long timeout;
- private long createTime;
- private Throwable exception = null;
- private List> promiseListenerList;
-
- public DefaultPromise() {
- createTime = System.currentTimeMillis();
- promiseListenerList = new ArrayList<>();
- timeout = 5000;
- }
-
- @Override
- public boolean cancel(final boolean mayInterruptIfRunning) {
- return false;
- }
-
- @Override
- public boolean isCancelled() {
- return state.isCancelledState();
- }
-
- @Override
- public boolean isDone() {
- return state.isDoneState();
- }
-
- @Override
- public V get() {
- return result;
- }
-
- @Override
- public V get(final long timeout) {
- synchronized (lock) {
- if (!isDoing()) {
- return getValueOrThrowable();
- }
-
- if (timeout <= 0) {
- try {
- lock.wait();
- } catch (Exception e) {
- cancel(e);
- }
- return getValueOrThrowable();
- } else {
- long waitTime = timeout - (System.currentTimeMillis() - createTime);
- if (waitTime > 0) {
- for (; ; ) {
- try {
- lock.wait(waitTime);
- } catch (InterruptedException e) {
- LOG.error("promise get value interrupted,excepiton:{}", e.getMessage());
- }
-
- if (!isDoing()) {
- break;
- } else {
- waitTime = timeout - (System.currentTimeMillis() - createTime);
- if (waitTime <= 0) {
- break;
- }
- }
- }
- }
-
- if (isDoing()) {
- timeoutSoCancel();
- }
- }
- return getValueOrThrowable();
- }
- }
-
- public boolean set(final V value) {
- if (value == null) {
- return false;
- }
- this.result = value;
- return done();
- }
-
- public boolean setFailure(final Throwable cause) {
- if (cause == null) {
- return false;
- }
- this.exception = cause;
- return done();
- }
-
- @Override
- public void addListener(final FutureListener listener) {
- if (listener == null) {
- throw new NullPointerException("FutureListener is null");
- }
-
- boolean notifyNow = false;
- synchronized (lock) {
- if (!isDoing()) {
- notifyNow = true;
- } else {
- if (promiseListenerList == null) {
- promiseListenerList = new ArrayList<>();
- }
- promiseListenerList.add(listener);
- }
- }
-
- if (notifyNow) {
- notifyListener(listener);
- }
- }
-
- @Override
- public Throwable getThrowable() {
- return exception;
- }
-
- private void notifyListeners() {
- if (promiseListenerList != null) {
- for (FutureListener listener : promiseListenerList) {
- notifyListener(listener);
- }
- }
- }
-
- private boolean isSuccess() {
- return isDone() && (exception == null);
- }
-
- private void timeoutSoCancel() {
- synchronized (lock) {
- if (!isDoing()) {
- return;
- }
- state = FutureState.CANCELLED;
- exception = new RuntimeException("Get request result is timeout or interrupted");
- lock.notifyAll();
- }
- notifyListeners();
- }
-
- private V getValueOrThrowable() {
- if (exception != null) {
- Throwable e = exception.getCause() != null ? exception.getCause() : exception;
- throw new OMSRuntimeException("-1", e);
- }
- notifyListeners();
- return result;
- }
-
- private boolean isDoing() {
- return state.isDoingState();
- }
-
- private boolean done() {
- synchronized (lock) {
- if (!isDoing()) {
- return false;
- }
-
- state = FutureState.DONE;
- lock.notifyAll();
- }
-
- notifyListeners();
- return true;
- }
-
- private void notifyListener(final FutureListener listener) {
- try {
- listener.operationComplete(this);
- } catch (Throwable t) {
- LOG.error("notifyListener {} Error:{}", listener.getClass().getSimpleName(), t);
- }
- }
-
- private boolean cancel(Exception e) {
- synchronized (lock) {
- if (!isDoing()) {
- return false;
- }
-
- state = FutureState.CANCELLED;
- exception = e;
- lock.notifyAll();
- }
-
- notifyListeners();
- return true;
- }
-}
-
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/utils/CloudEventUtils.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/utils/CloudEventUtils.java
new file mode 100644
index 0000000000..2073468895
--- /dev/null
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/utils/CloudEventUtils.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.rocketmq.utils;
+
+import org.apache.eventmesh.api.SendResult;
+import org.apache.eventmesh.common.Constants;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageAccessor;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageExt;
+
+import java.util.Map;
+import java.util.Set;
+
+public class CloudEventUtils {
+
+ public static SendResult convertSendResult(
+ org.apache.rocketmq.client.producer.SendResult rmqResult) {
+ SendResult sendResult = new SendResult();
+ sendResult.setTopic(rmqResult.getMessageQueue().getTopic());
+ sendResult.setMessageId(rmqResult.getMsgId());
+ return sendResult;
+ }
+
+
+ public static Message msgConvert(MessageExt rmqMsg) {
+ Message message = new Message();
+ if (rmqMsg.getTopic() != null) {
+ message.setTopic(rmqMsg.getTopic());
+ }
+
+ if (rmqMsg.getKeys() != null) {
+ message.setKeys(rmqMsg.getKeys());
+ }
+
+ if (rmqMsg.getTags() != null) {
+ message.setTags(rmqMsg.getTags());
+ }
+
+ if (rmqMsg.getBody() != null) {
+ message.setBody(rmqMsg.getBody());
+ }
+
+ final Set> entries = rmqMsg.getProperties().entrySet();
+
+ for (final Map.Entry entry : entries) {
+ MessageAccessor.putProperty(message, entry.getKey(), entry.getValue());
+ }
+
+ if (rmqMsg.getMsgId() != null) {
+ MessageAccessor.putProperty(message, buildCloudEventPropertyKey(Constants.PROPERTY_MESSAGE_MESSAGE_ID),
+ rmqMsg.getMsgId());
+ }
+
+ if (rmqMsg.getTopic() != null) {
+ MessageAccessor.putProperty(message, buildCloudEventPropertyKey(Constants.PROPERTY_MESSAGE_DESTINATION),
+ rmqMsg.getTopic());
+ }
+
+ //
+ MessageAccessor.putProperty(message, buildCloudEventPropertyKey(Constants.PROPERTY_MESSAGE_BORN_HOST),
+ String.valueOf(rmqMsg.getBornHost()));
+ MessageAccessor.putProperty(message, buildCloudEventPropertyKey(Constants.PROPERTY_MESSAGE_BORN_TIMESTAMP),
+ String.valueOf(rmqMsg.getBornTimestamp()));
+ MessageAccessor.putProperty(message, buildCloudEventPropertyKey(Constants.PROPERTY_MESSAGE_STORE_HOST),
+ String.valueOf(rmqMsg.getStoreHost()));
+ MessageAccessor.putProperty(message, buildCloudEventPropertyKey(Constants.PROPERTY_MESSAGE_STORE_TIMESTAMP),
+ String.valueOf(rmqMsg.getStoreTimestamp()));
+
+ //use in manual ack
+ MessageAccessor.putProperty(message, buildCloudEventPropertyKey(Constants.PROPERTY_MESSAGE_QUEUE_ID),
+ String.valueOf(rmqMsg.getQueueId()));
+ MessageAccessor.putProperty(message, buildCloudEventPropertyKey(Constants.PROPERTY_MESSAGE_QUEUE_OFFSET),
+ String.valueOf(rmqMsg.getQueueOffset()));
+
+ for (String sysPropKey : MessageConst.STRING_HASH_SET) {
+ if (StringUtils.isNotEmpty(message.getProperty(sysPropKey))) {
+ String prop = message.getProperty(sysPropKey);
+ String tmpPropKey = sysPropKey.toLowerCase().replaceAll("_", Constants.MESSAGE_PROP_SEPARATOR);
+ MessageAccessor.putProperty(message, tmpPropKey, prop);
+ message.getProperties().remove(sysPropKey);
+ }
+ }
+
+ return message;
+ }
+
+
+
+ private static String buildCloudEventPropertyKey(String propName) {
+ //return RocketMQHeaders.CE_PREFIX + propName;
+ return propName;
+ }
+
+ public static org.apache.rocketmq.common.message.MessageExt msgConvertExt(Message message) {
+
+ org.apache.rocketmq.common.message.MessageExt rmqMessageExt =
+ new org.apache.rocketmq.common.message.MessageExt();
+ try {
+ if (message.getKeys() != null) {
+ rmqMessageExt.setKeys(message.getKeys());
+ }
+ if (message.getTags() != null) {
+ rmqMessageExt.setTags(message.getTags());
+ }
+
+
+ if (message.getBody() != null) {
+ rmqMessageExt.setBody(message.getBody());
+ }
+
+
+ //All destinations in RocketMQ use Topic
+ rmqMessageExt.setTopic(message.getTopic());
+
+ int queueId =
+ Integer.parseInt(message.getProperty(buildCloudEventPropertyKey(Constants.PROPERTY_MESSAGE_QUEUE_ID)));
+ long queueOffset = Long.parseLong(
+ message.getProperty(buildCloudEventPropertyKey(Constants.PROPERTY_MESSAGE_QUEUE_OFFSET)));
+ //use in manual ack
+ rmqMessageExt.setQueueId(queueId);
+ rmqMessageExt.setQueueOffset(queueOffset);
+ Map properties = message.getProperties();
+ for (final Map.Entry entry : properties.entrySet()) {
+ MessageAccessor.putProperty(rmqMessageExt, entry.getKey(), entry.getValue());
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return rmqMessageExt;
+
+ }
+
+
+}
diff --git a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/utils/OMSUtil.java b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/utils/OMSUtil.java
index 00bcb85f2a..dd2a36bd8a 100644
--- a/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/utils/OMSUtil.java
+++ b/eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/utils/OMSUtil.java
@@ -24,10 +24,6 @@
import java.util.Properties;
import java.util.Set;
-import io.openmessaging.api.Message;
-import io.openmessaging.api.OMSBuiltinKeys;
-import io.openmessaging.api.SendResult;
-import io.openmessaging.api.exception.OMSRuntimeException;
import org.apache.eventmesh.common.Constants;
import org.apache.rocketmq.common.UtilAll;
@@ -42,255 +38,255 @@ public class OMSUtil {
* @return a unique instance name
*/
public static String buildInstanceName() {
- return Integer.toString(UtilAll.getPid()) + "%OpenMessaging" + "%" + System.nanoTime();
+ return Integer.toString(UtilAll.getPid()) + "%EventMesh" + "%" + System.nanoTime();
}
- public static org.apache.rocketmq.common.message.Message msgConvert(Message omsMessage) {
- org.apache.rocketmq.common.message.Message rmqMessage = new org.apache.rocketmq.common.message.Message();
- if (omsMessage == null) {
- throw new OMSRuntimeException("'message' is null");
- } else {
- if (omsMessage.getTopic() != null) {
- rmqMessage.setTopic(omsMessage.getTopic());
- }
- if (omsMessage.getKey() != null) {
- rmqMessage.setKeys(omsMessage.getKey());
- }
- if (omsMessage.getTag() != null) {
- rmqMessage.setTags(omsMessage.getTag());
- }
- if (omsMessage.getStartDeliverTime() > 0L) {
- rmqMessage.putUserProperty("TIMER_DELIVER_MS", String.valueOf(omsMessage.getStartDeliverTime()));
- }
-
- if (omsMessage.getBody() != null) {
- rmqMessage.setBody(omsMessage.getBody());
- }
-
- if (omsMessage.getShardingKey() != null && !omsMessage.getShardingKey().isEmpty()) {
- rmqMessage.putUserProperty("__SHARDINGKEY", omsMessage.getShardingKey());
- }
- }
- Properties systemProperties = omsMessage.getSystemProperties();
- Properties userProperties = omsMessage.getUserProperties();
-
- //All destinations in RocketMQ use Topic
-// rmqMessage.setTopic(systemProperties.getProperty(BuiltinKeys.DESTINATION));
-
-// if (sysHeaders.containsKey(BuiltinKeys.START_TIME)) {
-// long deliverTime = sysHeaders.getLong(BuiltinKeys.START_TIME, 0);
-// if (deliverTime > 0) {
-// rmqMessage.putUserProperty(RocketMQConstants.START_DELIVER_TIME, String.valueOf(deliverTime));
+// public static org.apache.rocketmq.common.message.Message msgConvert(Message omsMessage) {
+// org.apache.rocketmq.common.message.Message rmqMessage = new org.apache.rocketmq.common.message.Message();
+// if (omsMessage == null) {
+// throw new OMSRuntimeException("'message' is null");
+// } else {
+// if (omsMessage.getTopic() != null) {
+// rmqMessage.setTopic(omsMessage.getTopic());
+// }
+// if (omsMessage.getKey() != null) {
+// rmqMessage.setKeys(omsMessage.getKey());
+// }
+// if (omsMessage.getTag() != null) {
+// rmqMessage.setTags(omsMessage.getTag());
+// }
+// if (omsMessage.getStartDeliverTime() > 0L) {
+// rmqMessage.putUserProperty("TIMER_DELIVER_MS", String.valueOf(omsMessage.getStartDeliverTime()));
+// }
+//
+// if (omsMessage.getBody() != null) {
+// rmqMessage.setBody(omsMessage.getBody());
+// }
+//
+// if (omsMessage.getShardingKey() != null && !omsMessage.getShardingKey().isEmpty()) {
+// rmqMessage.putUserProperty("__SHARDINGKEY", omsMessage.getShardingKey());
// }
// }
-
- for (String key : userProperties.stringPropertyNames()) {
- MessageAccessor.putProperty(rmqMessage, key, userProperties.getProperty(key));
- }
-
- //System headers has a high priority
- for (String key : systemProperties.stringPropertyNames()) {
- MessageAccessor.putProperty(rmqMessage, key, systemProperties.getProperty(key));
- }
-
- return rmqMessage;
- }
-
- public static Message msgConvert(MessageExt rmqMsg) {
- Message message = new Message();
- if (rmqMsg.getTopic() != null) {
- message.setTopic(rmqMsg.getTopic());
- }
-
- if (rmqMsg.getKeys() != null) {
- message.setKey(rmqMsg.getKeys());
- }
-
- if (rmqMsg.getTags() != null) {
- message.setTag(rmqMsg.getTags());
- }
-
- if (rmqMsg.getBody() != null) {
- message.setBody(rmqMsg.getBody());
- }
-
- if (rmqMsg.getUserProperty("TIMER_DELIVER_MS") != null) {
- long ms = Long.parseLong(rmqMsg.getUserProperty("TIMER_DELIVER_MS"));
- rmqMsg.getProperties().remove("TIMER_DELIVER_MS");
- message.setStartDeliverTime(ms);
- }
-
- Properties systemProperties = new Properties();
- Properties userProperties = new Properties();
-
-
- final Set> entries = rmqMsg.getProperties().entrySet();
-
- for (final Map.Entry entry : entries) {
- if (isOMSHeader(entry.getKey())) {
- //sysHeader
- systemProperties.put(entry.getKey(), entry.getValue());
- } else {
- //userHeader
- userProperties.put(entry.getKey(), entry.getValue());
- }
- }
-
- if (rmqMsg.getMsgId() != null){
- systemProperties.put(Constants.PROPERTY_MESSAGE_MESSAGE_ID, rmqMsg.getMsgId());
- }
-
- if (rmqMsg.getTopic() != null){
- systemProperties.put(Constants.PROPERTY_MESSAGE_DESTINATION, rmqMsg.getTopic());
- }
-
-// omsMsg.putSysHeaders(BuiltinKeys.SEARCH_KEYS, rmqMsg.getKeys());
- systemProperties.put(Constants.PROPERTY_MESSAGE_BORN_HOST, String.valueOf(rmqMsg.getBornHost()));
- systemProperties.put(Constants.PROPERTY_MESSAGE_BORN_TIMESTAMP, rmqMsg.getBornTimestamp());
- systemProperties.put(Constants.PROPERTY_MESSAGE_STORE_HOST, String.valueOf(rmqMsg.getStoreHost()));
- systemProperties.put("STORE_TIMESTAMP", rmqMsg.getStoreTimestamp());
-
- //use in manual ack
- userProperties.put(Constants.PROPERTY_MESSAGE_QUEUE_ID, rmqMsg.getQueueId());
- userProperties.put(Constants.PROPERTY_MESSAGE_QUEUE_OFFSET, rmqMsg.getQueueOffset());
-
- message.setSystemProperties(systemProperties);
- message.setUserProperties(userProperties);
-
- return message;
- }
-
- public static org.apache.rocketmq.common.message.MessageExt msgConvertExt(Message omsMessage) {
-
- org.apache.rocketmq.common.message.MessageExt rmqMessageExt = new org.apache.rocketmq.common.message.MessageExt();
- try {
- if (omsMessage.getKey() != null) {
- rmqMessageExt.setKeys(omsMessage.getKey());
- }
- if (omsMessage.getTag() != null) {
- rmqMessageExt.setTags(omsMessage.getTag());
- }
- if (omsMessage.getStartDeliverTime() > 0L) {
- rmqMessageExt.putUserProperty("TIMER_DELIVER_MS", String.valueOf(omsMessage.getStartDeliverTime()));
- }
-
- if (omsMessage.getBody() != null) {
- rmqMessageExt.setBody(omsMessage.getBody());
- }
-
- if (omsMessage.getShardingKey() != null && !omsMessage.getShardingKey().isEmpty()) {
- rmqMessageExt.putUserProperty("__SHARDINGKEY", omsMessage.getShardingKey());
- }
-
- Properties systemProperties = omsMessage.getSystemProperties();
- Properties userProperties = omsMessage.getUserProperties();
-
- //All destinations in RocketMQ use Topic
- rmqMessageExt.setTopic(omsMessage.getTopic());
-
- int queueId = (int) userProperties.get(Constants.PROPERTY_MESSAGE_QUEUE_ID);
- long queueOffset = (long) userProperties.get(Constants.PROPERTY_MESSAGE_QUEUE_OFFSET);
- //use in manual ack
- rmqMessageExt.setQueueId(queueId);
- rmqMessageExt.setQueueOffset(queueOffset);
-
- for (String key : userProperties.stringPropertyNames()) {
- MessageAccessor.putProperty(rmqMessageExt, key, userProperties.getProperty(key));
- }
-
- //System headers has a high priority
- for (String key : systemProperties.stringPropertyNames()) {
- MessageAccessor.putProperty(rmqMessageExt, key, systemProperties.getProperty(key));
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- return rmqMessageExt;
-
- }
-
- public static boolean isOMSHeader(String value) {
- for (Field field : OMSBuiltinKeys.class.getDeclaredFields()) {
- try {
- if (field.get(OMSBuiltinKeys.class).equals(value)) {
- return true;
- }
- } catch (IllegalAccessException e) {
- return false;
- }
- }
- return false;
- }
-
- /**
- * Convert a RocketMQ SEND_OK SendResult instance to a OMS SendResult.
- *
- * @param rmqResult RocketMQ result
- * @return send result
- */
- public static SendResult sendResultConvert(org.apache.rocketmq.client.producer.SendResult rmqResult) {
- SendResult sendResult = new SendResult();
- sendResult.setTopic(rmqResult.getMessageQueue().getTopic());
- sendResult.setMessageId(rmqResult.getMsgId());
- return sendResult;
- }
-
-// public static KeyValue buildKeyValue(KeyValue... keyValues) {
-// KeyValue keyValue = OMS.newKeyValue();
-// for (KeyValue properties : keyValues) {
-// for (String key : properties.keySet()) {
-// keyValue.put(key, properties.getString(key));
+// Properties systemProperties = omsMessage.getSystemProperties();
+// Properties userProperties = omsMessage.getUserProperties();
+//
+// //All destinations in RocketMQ use Topic
+//// rmqMessage.setTopic(systemProperties.getProperty(BuiltinKeys.DESTINATION));
+//
+//// if (sysHeaders.containsKey(BuiltinKeys.START_TIME)) {
+//// long deliverTime = sysHeaders.getLong(BuiltinKeys.START_TIME, 0);
+//// if (deliverTime > 0) {
+//// rmqMessage.putUserProperty(RocketMQConstants.START_DELIVER_TIME, String.valueOf(deliverTime));
+//// }
+//// }
+//
+// for (String key : userProperties.stringPropertyNames()) {
+// MessageAccessor.putProperty(rmqMessage, key, userProperties.getProperty(key));
+// }
+//
+// //System headers has a high priority
+// for (String key : systemProperties.stringPropertyNames()) {
+// MessageAccessor.putProperty(rmqMessage, key, systemProperties.getProperty(key));
+// }
+//
+// return rmqMessage;
+// }
+//
+// public static Message msgConvert(MessageExt rmqMsg) {
+// Message message = new Message();
+// if (rmqMsg.getTopic() != null) {
+// message.setTopic(rmqMsg.getTopic());
+// }
+//
+// if (rmqMsg.getKeys() != null) {
+// message.setKey(rmqMsg.getKeys());
+// }
+//
+// if (rmqMsg.getTags() != null) {
+// message.setTag(rmqMsg.getTags());
+// }
+//
+// if (rmqMsg.getBody() != null) {
+// message.setBody(rmqMsg.getBody());
+// }
+//
+// if (rmqMsg.getUserProperty("TIMER_DELIVER_MS") != null) {
+// long ms = Long.parseLong(rmqMsg.getUserProperty("TIMER_DELIVER_MS"));
+// rmqMsg.getProperties().remove("TIMER_DELIVER_MS");
+// message.setStartDeliverTime(ms);
+// }
+//
+// Properties systemProperties = new Properties();
+// Properties userProperties = new Properties();
+//
+//
+// final Set> entries = rmqMsg.getProperties().entrySet();
+//
+// for (final Map.Entry