Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update Eventmeshmessage plugin #599

Merged
merged 40 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
fb84d90
[Feature #564] Support CloudEvents protocols for pub/sub in EventMesh…
xwm1992 Oct 28, 2021
4e55912
support cloudevents api in eventmesh-connector-api module
xwm1992 Nov 1, 2021
e602004
Merge branch 'develop' of https://github.com/apache/incubator-eventme…
xwm1992 Nov 1, 2021
9adb5e9
Merge branch 'develop' of https://github.com/apache/incubator-eventme…
xwm1992 Nov 1, 2021
670c2f2
fix checkStyle
xwm1992 Nov 1, 2021
691bcb3
fix checkStyle
xwm1992 Nov 1, 2021
b6a4613
fix checkStyle
xwm1992 Nov 1, 2021
0ac6d4f
1.support LifeCycle.java
xwm1992 Nov 1, 2021
2239a65
fix remove the extra blank line
xwm1992 Nov 1, 2021
086f4e6
Merge branch 'cloudevents' of https://github.com/apache/incubator-eve…
xwm1992 Nov 2, 2021
308dfd7
support cloudEvents
xwm1992 Nov 2, 2021
f288ae2
Add files via upload
qqeasonchen Nov 3, 2021
09b9a22
Update README.md
qqeasonchen Nov 3, 2021
f0f3108
support cloudEvents
xwm1992 Nov 8, 2021
0290837
support cloudEvents
xwm1992 Nov 9, 2021
90a28cc
[ISSUE #580] Add checkstyle gradle plugin (#581)
ruanwenjun Nov 10, 2021
4425aaf
support cloudEvents
xwm1992 Nov 10, 2021
0dce0ca
support cloudevents
xwm1992 Nov 10, 2021
9251e07
update wechat-official qr code
xwm1992 Nov 11, 2021
ff1c247
update mesh-helper qr code
xwm1992 Nov 11, 2021
00994c3
Add files via upload
qqeasonchen Nov 11, 2021
bcf0337
update README.md
xwm1992 Nov 11, 2021
4938cd7
update README.md
xwm1992 Nov 11, 2021
61d0410
Update .asf.yaml
qqeasonchen Nov 11, 2021
3166325
support cloudEvents
xwm1992 Nov 11, 2021
bbd3535
support cloudEvents
xwm1992 Nov 12, 2021
de99c54
Merge branch 'cloudevents' of https://github.com/apache/incubator-eve…
xwm1992 Nov 12, 2021
ceaf33b
[ISSUE #588] Fix typo in README.md (#589)
nichozhan Nov 15, 2021
468386c
Merge branch 'cloudevents' of https://github.com/apache/incubator-eve…
xwm1992 Nov 16, 2021
d2d2b7d
support cloudEvents
xwm1992 Nov 16, 2021
46f973d
[Bug #590] Consumer subscription topic is invalid (#590) (#592)
hagsyn Nov 16, 2021
cf8433a
support cloudEvents adaptor
xwm1992 Nov 16, 2021
18310a1
[Feature #562] Implement CloudEvents adaptor
xwm1992 Nov 17, 2021
3149552
Merge branch 'develop' of https://github.com/apache/incubator-eventme…
xwm1992 Nov 17, 2021
d7ddac8
Merge branch 'cloudevents' of https://github.com/apache/incubator-eve…
xwm1992 Nov 17, 2021
c534985
[Feature #562] Implement EventMeshMessage protocol adaptor
xwm1992 Nov 18, 2021
024e462
Merge branch 'cloudevents' of https://github.com/apache/incubator-eve…
xwm1992 Nov 18, 2021
f096294
supplement apache header
xwm1992 Nov 18, 2021
46d8a51
Merge branch 'cloudevents' of https://github.com/apache/incubator-eve…
xwm1992 Nov 19, 2021
0f34e98
1.update package name
xwm1992 Nov 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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-protocol-plugin:eventmesh-protocol-api")
implementation "io.cloudevents:cloudevents-core"

testImplementation project(":eventmesh-protocol-plugin:eventmesh-protocol-api")
testImplementation "io.cloudevents:cloudevents-core"
testImplementation "junit:junit"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.
#

pluginType=protocol
pluginName=eventmeshmessage
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,32 @@
* limitations under the License.
*/

package org.apache.eventmesh.protocol.eventmeshmessage;
package org.apache.eventmesh.protocol.meshmessage;

import io.cloudevents.CloudEvent;
import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.ProtocolTransportObject;
import org.apache.eventmesh.common.command.HttpCommand;
import org.apache.eventmesh.common.protocol.http.body.Body;
import org.apache.eventmesh.common.protocol.http.common.RequestCode;
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.protocol.api.ProtocolAdaptor;
import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException;
import org.apache.eventmesh.protocol.eventmeshmessage.resolver.http.SendMessageBatchProtocolResolver;
import org.apache.eventmesh.protocol.eventmeshmessage.resolver.http.SendMessageBatchV2ProtocolResolver;
import org.apache.eventmesh.protocol.eventmeshmessage.resolver.http.SendMessageRequestProtocolResolver;
import org.apache.eventmesh.protocol.eventmeshmessage.resolver.tcp.TcpMessageProtocolResolver;
import org.apache.eventmesh.protocol.meshmessage.resolver.http.SendMessageBatchProtocolResolver;
import org.apache.eventmesh.protocol.meshmessage.resolver.http.SendMessageBatchV2ProtocolResolver;
import org.apache.eventmesh.protocol.meshmessage.resolver.http.SendMessageRequestProtocolResolver;
import org.apache.eventmesh.protocol.meshmessage.resolver.tcp.TcpMessageProtocolResolver;

import java.nio.charset.StandardCharsets;
import java.util.List;

public class EventMeshMessageProtocolAdaptor<T> implements ProtocolAdaptor<T> {
public class MeshMessageProtocolAdaptor<T extends ProtocolTransportObject>
implements ProtocolAdaptor<ProtocolTransportObject> {

@Override
public CloudEvent toCloudEvent(T protocol) throws ProtocolHandleException {
public CloudEvent toCloudEvent(ProtocolTransportObject protocol) throws ProtocolHandleException {
if (protocol instanceof Package) {
Header header = ((Package) protocol).getHeader();
Object body = ((Package) protocol).getBody();
Expand Down Expand Up @@ -78,16 +79,18 @@ private CloudEvent deserializeHttpProtocol(String requestCode, org.apache.eventm
}

@Override
public List<CloudEvent> toBatchCloudEvent(T protocol) throws ProtocolHandleException {
public List<CloudEvent> toBatchCloudEvent(ProtocolTransportObject protocol) throws ProtocolHandleException {
return null;
}

@Override
public Object fromCloudEvent(CloudEvent cloudEvent) throws ProtocolHandleException {
public ProtocolTransportObject fromCloudEvent(CloudEvent cloudEvent) throws ProtocolHandleException {
String protocolDesc = cloudEvent.getExtension(Constants.PROTOCOL_DESC).toString();

if (StringUtils.equals("http", protocolDesc)) {
return new String(cloudEvent.getData().toBytes(), StandardCharsets.UTF_8);
// todo: return command, set cloudEvent.getData() to content?
return null;
// return new String(cloudEvent.getData().toBytes(), StandardCharsets.UTF_8);
} else if (StringUtils.equals("tcp", protocolDesc)) {
return TcpMessageProtocolResolver.buildEventMeshMessage(cloudEvent);
} else {
Expand All @@ -97,6 +100,6 @@ public Object fromCloudEvent(CloudEvent cloudEvent) throws ProtocolHandleExcepti

@Override
public String getProtocolType() {
return EventMeshMessageProtocolConstant.PROTOCOL_NAME;
return MeshMessageProtocolConstant.PROTOCOL_NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* limitations under the License.
*/

package org.apache.eventmesh.protocol.eventmeshmessage;
package org.apache.eventmesh.protocol.meshmessage;

public enum EventMeshMessageProtocolConstant {
public enum MeshMessageProtocolConstant {
;
public static final String PROTOCOL_NAME = "eventmeshmessage";
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.eventmesh.protocol.eventmeshmessage.resolver.http;
package org.apache.eventmesh.protocol.meshmessage.resolver.http;

import io.cloudevents.CloudEvent;
import org.apache.eventmesh.common.protocol.http.body.Body;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,18 @@
* limitations under the License.
*/

package org.apache.eventmesh.protocol.eventmeshmessage.resolver.http;
package org.apache.eventmesh.protocol.meshmessage.resolver.http;

import io.cloudevents.CloudEvent;
import io.cloudevents.SpecVersion;
import io.cloudevents.core.builder.CloudEventBuilder;
import io.cloudevents.core.v03.CloudEventV03;
import io.cloudevents.core.v1.CloudEventV1;
import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.protocol.http.body.Body;
import org.apache.eventmesh.common.protocol.http.body.message.SendMessageBatchV2RequestBody;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.apache.eventmesh.common.protocol.http.header.Header;
import org.apache.eventmesh.common.protocol.http.header.message.SendMessageBatchV2RequestHeader;
import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage;
import org.apache.eventmesh.common.utils.JsonUtils;
import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException;

import java.nio.charset.StandardCharsets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
* limitations under the License.
*/

package org.apache.eventmesh.protocol.eventmeshmessage.resolver.http;
package org.apache.eventmesh.protocol.meshmessage.resolver.http;

import io.cloudevents.CloudEvent;
import io.cloudevents.SpecVersion;
import io.cloudevents.core.builder.CloudEventBuilder;
import io.cloudevents.core.v03.CloudEventV03;
import io.cloudevents.core.v1.CloudEventV1;
import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.protocol.http.body.Body;
import org.apache.eventmesh.common.protocol.http.body.message.SendMessageBatchV2RequestBody;
Expand All @@ -30,7 +28,6 @@
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.apache.eventmesh.common.protocol.http.header.Header;
import org.apache.eventmesh.common.protocol.http.header.message.SendMessageRequestHeader;
import org.apache.eventmesh.common.utils.JsonUtils;
import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException;

import java.nio.charset.StandardCharsets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.eventmesh.protocol.eventmeshmessage.resolver.tcp;
package org.apache.eventmesh.protocol.meshmessage.resolver.tcp;

import io.cloudevents.CloudEvent;
import io.cloudevents.SpecVersion;
Expand All @@ -26,7 +26,7 @@
import org.apache.eventmesh.common.protocol.tcp.Header;
import org.apache.eventmesh.common.protocol.tcp.Package;
import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException;
import org.apache.eventmesh.protocol.eventmeshmessage.EventMeshMessageProtocolConstant;
import org.apache.eventmesh.protocol.meshmessage.MeshMessageProtocolConstant;

import java.nio.charset.StandardCharsets;
import java.util.HashMap;
Expand All @@ -50,7 +50,7 @@ public static CloudEvent buildEvent(Header header, Object body) throws ProtocolH
protocolType, protocolVersion, protocolDesc));
}

if (!StringUtils.equals(EventMeshMessageProtocolConstant.PROTOCOL_NAME, protocolType)) {
if (!StringUtils.equals(MeshMessageProtocolConstant.PROTOCOL_NAME, protocolType)) {
throw new ProtocolHandleException(String.format("Unsupported protocolType: %s", protocolType));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

eventmeshmessage=org.apache.eventmesh.protocol.eventmeshmessage.EventMeshMessageProtocolAdaptor
eventmeshmessage=org.apache.eventmesh.protocol.meshmessage.MeshMessageProtocolAdaptor
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ include 'eventmesh-protocol-plugin'
include 'eventmesh-protocol-plugin:eventmesh-protocol-api'
include 'eventmesh-protocol-plugin:eventmesh-protocol-openmessage'
include 'eventmesh-protocol-plugin:eventmesh-protocol-cloudevents'
include 'eventmesh-protocol-plugin:eventmesh-protocol-eventmeshmessage'
include 'eventmesh-protocol-plugin:eventmesh-protocol-meshmessage'