Skip to content

Commit 40adf00

Browse files
authored
Merge cb96b92 into 54cd00f
2 parents 54cd00f + cb96b92 commit 40adf00

File tree

21 files changed

+613
-274
lines changed

21 files changed

+613
-274
lines changed

eventmesh-common/src/main/java/org/apache/eventmesh/common/EventMeshMessage.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,13 @@ public class EventMeshMessage {
3838

3939
private String content;
4040

41-
private Map<String, String> prop;
41+
@Builder.Default
42+
private Map<String, String> prop = new HashMap<>();
4243

4344
@Builder.Default
4445
private final long createTime = System.currentTimeMillis();
4546

4647
public EventMeshMessage addProp(String key, String val) {
47-
if (prop == null) {
48-
prop = new HashMap<>();
49-
}
5048
prop.put(key, val);
5149
return this;
5250
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.eventmesh.common.enums;
19+
20+
public enum EventMeshProtocolType {
21+
22+
CLOUD_EVENTS("cloudevents"),
23+
EVENT_MESH_MESSAGE("eventmeshmessage"),
24+
OPEN_MESSAGE("openmessage");
25+
26+
private String name;
27+
28+
EventMeshProtocolType(String name) {
29+
this.name = name;
30+
}
31+
32+
public String protocolTypeName() {
33+
return this.name;
34+
}
35+
36+
public static EventMeshProtocolType eventMeshProtocolType(String name) {
37+
for (EventMeshProtocolType protocolType : EventMeshProtocolType.values()) {
38+
if (protocolType.protocolTypeName().equals(name)) {
39+
return protocolType;
40+
}
41+
}
42+
return null;
43+
}
44+
45+
}

eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/CloudEventsAsyncSubscribe.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
import org.apache.eventmesh.client.grpc.consumer.EventMeshGrpcConsumer;
2121
import org.apache.eventmesh.client.grpc.consumer.ReceiveMsgHook;
22-
import org.apache.eventmesh.client.tcp.common.EventMeshCommon;
2322
import org.apache.eventmesh.common.ExampleConstants;
23+
import org.apache.eventmesh.common.enums.EventMeshProtocolType;
2424
import org.apache.eventmesh.common.protocol.SubscriptionItem;
2525
import org.apache.eventmesh.common.protocol.SubscriptionMode;
2626
import org.apache.eventmesh.common.protocol.SubscriptionType;
@@ -68,7 +68,7 @@ public Optional<CloudEvent> handle(final CloudEvent msg) {
6868
}
6969

7070
@Override
71-
public String getProtocolType() {
72-
return EventMeshCommon.CLOUD_EVENTS_PROTOCOL_NAME;
71+
public EventMeshProtocolType getProtocolType() {
72+
return EventMeshProtocolType.CLOUD_EVENTS;
7373
}
7474
}

eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/CloudEventsSubscribeReply.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
import org.apache.eventmesh.client.grpc.consumer.EventMeshGrpcConsumer;
2121
import org.apache.eventmesh.client.grpc.consumer.ReceiveMsgHook;
22-
import org.apache.eventmesh.client.tcp.common.EventMeshCommon;
2322
import org.apache.eventmesh.common.ExampleConstants;
23+
import org.apache.eventmesh.common.enums.EventMeshProtocolType;
2424
import org.apache.eventmesh.common.protocol.SubscriptionItem;
2525
import org.apache.eventmesh.common.protocol.SubscriptionMode;
2626
import org.apache.eventmesh.common.protocol.SubscriptionType;
@@ -74,7 +74,7 @@ public Optional<CloudEvent> handle(final CloudEvent msg) {
7474
}
7575

7676
@Override
77-
public String getProtocolType() {
78-
return EventMeshCommon.CLOUD_EVENTS_PROTOCOL_NAME;
77+
public EventMeshProtocolType getProtocolType() {
78+
return EventMeshProtocolType.CLOUD_EVENTS;
7979
}
8080
}

eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/EventMeshAsyncSubscribe.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020
import org.apache.eventmesh.client.grpc.consumer.EventMeshGrpcConsumer;
2121
import org.apache.eventmesh.client.grpc.consumer.ReceiveMsgHook;
22-
import org.apache.eventmesh.client.tcp.common.EventMeshCommon;
2322
import org.apache.eventmesh.common.EventMeshMessage;
2423
import org.apache.eventmesh.common.ExampleConstants;
24+
import org.apache.eventmesh.common.enums.EventMeshProtocolType;
2525
import org.apache.eventmesh.common.protocol.SubscriptionItem;
2626
import org.apache.eventmesh.common.protocol.SubscriptionMode;
2727
import org.apache.eventmesh.common.protocol.SubscriptionType;
@@ -33,7 +33,6 @@
3333
import java.util.Optional;
3434
import java.util.concurrent.TimeUnit;
3535

36-
3736
import lombok.extern.slf4j.Slf4j;
3837

3938
@Slf4j
@@ -68,7 +67,7 @@ public Optional<EventMeshMessage> handle(final EventMeshMessage msg) {
6867
}
6968

7069
@Override
71-
public String getProtocolType() {
72-
return EventMeshCommon.EM_MESSAGE_PROTOCOL_NAME;
70+
public EventMeshProtocolType getProtocolType() {
71+
return EventMeshProtocolType.EVENT_MESH_MESSAGE;
7372
}
7473
}

eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/EventMeshSubscribeBroadcast.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020
import org.apache.eventmesh.client.grpc.consumer.EventMeshGrpcConsumer;
2121
import org.apache.eventmesh.client.grpc.consumer.ReceiveMsgHook;
22-
import org.apache.eventmesh.client.tcp.common.EventMeshCommon;
2322
import org.apache.eventmesh.common.EventMeshMessage;
2423
import org.apache.eventmesh.common.ExampleConstants;
24+
import org.apache.eventmesh.common.enums.EventMeshProtocolType;
2525
import org.apache.eventmesh.common.protocol.SubscriptionItem;
2626
import org.apache.eventmesh.common.protocol.SubscriptionMode;
2727
import org.apache.eventmesh.common.protocol.SubscriptionType;
@@ -33,7 +33,6 @@
3333
import java.util.Optional;
3434
import java.util.concurrent.TimeUnit;
3535

36-
3736
import lombok.extern.slf4j.Slf4j;
3837

3938
@Slf4j
@@ -69,7 +68,7 @@ public Optional<EventMeshMessage> handle(final EventMeshMessage msg) {
6968
}
7069

7170
@Override
72-
public String getProtocolType() {
73-
return EventMeshCommon.EM_MESSAGE_PROTOCOL_NAME;
71+
public EventMeshProtocolType getProtocolType() {
72+
return EventMeshProtocolType.EVENT_MESH_MESSAGE;
7473
}
7574
}

eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/EventMeshSubscribeReply.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020
import org.apache.eventmesh.client.grpc.consumer.EventMeshGrpcConsumer;
2121
import org.apache.eventmesh.client.grpc.consumer.ReceiveMsgHook;
22-
import org.apache.eventmesh.client.tcp.common.EventMeshCommon;
2322
import org.apache.eventmesh.common.EventMeshMessage;
2423
import org.apache.eventmesh.common.ExampleConstants;
24+
import org.apache.eventmesh.common.enums.EventMeshProtocolType;
2525
import org.apache.eventmesh.common.protocol.SubscriptionItem;
2626
import org.apache.eventmesh.common.protocol.SubscriptionMode;
2727
import org.apache.eventmesh.common.protocol.SubscriptionType;
@@ -33,7 +33,6 @@
3333
import java.util.Optional;
3434
import java.util.concurrent.TimeUnit;
3535

36-
3736
import lombok.extern.slf4j.Slf4j;
3837

3938
@Slf4j
@@ -72,7 +71,7 @@ public Optional<EventMeshMessage> handle(final EventMeshMessage msg) {
7271
}
7372

7473
@Override
75-
public String getProtocolType() {
76-
return EventMeshCommon.EM_MESSAGE_PROTOCOL_NAME;
74+
public EventMeshProtocolType getProtocolType() {
75+
return EventMeshProtocolType.EVENT_MESH_MESSAGE;
7776
}
7877
}

eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/WorkflowExpressAsyncSubscribe.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
import org.apache.eventmesh.client.grpc.consumer.EventMeshGrpcConsumer;
2323
import org.apache.eventmesh.client.grpc.consumer.ReceiveMsgHook;
2424
import org.apache.eventmesh.client.selector.SelectorFactory;
25-
import org.apache.eventmesh.client.tcp.common.EventMeshCommon;
2625
import org.apache.eventmesh.client.workflow.EventMeshWorkflowClient;
2726
import org.apache.eventmesh.client.workflow.config.EventMeshWorkflowClientConfig;
2827
import org.apache.eventmesh.common.EventMeshMessage;
2928
import org.apache.eventmesh.common.ExampleConstants;
29+
import org.apache.eventmesh.common.enums.EventMeshProtocolType;
3030
import org.apache.eventmesh.common.protocol.workflow.protos.ExecuteRequest;
3131
import org.apache.eventmesh.common.protocol.workflow.protos.ExecuteResponse;
3232
import org.apache.eventmesh.common.utils.ThreadUtils;
@@ -39,7 +39,6 @@
3939
import java.util.Properties;
4040
import java.util.concurrent.TimeUnit;
4141

42-
4342
import lombok.extern.slf4j.Slf4j;
4443

4544
@Slf4j
@@ -104,7 +103,7 @@ public Optional<EventMeshMessage> handle(final EventMeshMessage msg) throws Exce
104103
}
105104

106105
@Override
107-
public String getProtocolType() {
108-
return EventMeshCommon.EM_MESSAGE_PROTOCOL_NAME;
106+
public EventMeshProtocolType getProtocolType() {
107+
return EventMeshProtocolType.EVENT_MESH_MESSAGE;
109108
}
110109
}

eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/WorkflowOrderAsyncSubscribe.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
import org.apache.eventmesh.client.grpc.consumer.EventMeshGrpcConsumer;
2323
import org.apache.eventmesh.client.grpc.consumer.ReceiveMsgHook;
2424
import org.apache.eventmesh.client.selector.SelectorFactory;
25-
import org.apache.eventmesh.client.tcp.common.EventMeshCommon;
2625
import org.apache.eventmesh.client.workflow.EventMeshWorkflowClient;
2726
import org.apache.eventmesh.client.workflow.config.EventMeshWorkflowClientConfig;
2827
import org.apache.eventmesh.common.EventMeshMessage;
2928
import org.apache.eventmesh.common.ExampleConstants;
29+
import org.apache.eventmesh.common.enums.EventMeshProtocolType;
3030
import org.apache.eventmesh.common.protocol.workflow.protos.ExecuteRequest;
3131
import org.apache.eventmesh.common.protocol.workflow.protos.ExecuteResponse;
3232
import org.apache.eventmesh.common.utils.ThreadUtils;
@@ -39,7 +39,6 @@
3939
import java.util.Properties;
4040
import java.util.concurrent.TimeUnit;
4141

42-
4342
import lombok.extern.slf4j.Slf4j;
4443

4544
@Slf4j
@@ -100,7 +99,7 @@ public Optional<EventMeshMessage> handle(final EventMeshMessage msg) throws Exce
10099
}
101100

102101
@Override
103-
public String getProtocolType() {
104-
return EventMeshCommon.EM_MESSAGE_PROTOCOL_NAME;
102+
public EventMeshProtocolType getProtocolType() {
103+
return EventMeshProtocolType.EVENT_MESH_MESSAGE;
105104
}
106105
}

eventmesh-examples/src/main/java/org/apache/eventmesh/grpc/sub/WorkflowPaymentAsyncSubscribe.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
import org.apache.eventmesh.client.grpc.consumer.EventMeshGrpcConsumer;
2323
import org.apache.eventmesh.client.grpc.consumer.ReceiveMsgHook;
2424
import org.apache.eventmesh.client.selector.SelectorFactory;
25-
import org.apache.eventmesh.client.tcp.common.EventMeshCommon;
2625
import org.apache.eventmesh.client.workflow.EventMeshWorkflowClient;
2726
import org.apache.eventmesh.client.workflow.config.EventMeshWorkflowClientConfig;
2827
import org.apache.eventmesh.common.EventMeshMessage;
2928
import org.apache.eventmesh.common.ExampleConstants;
29+
import org.apache.eventmesh.common.enums.EventMeshProtocolType;
3030
import org.apache.eventmesh.common.protocol.workflow.protos.ExecuteRequest;
3131
import org.apache.eventmesh.common.protocol.workflow.protos.ExecuteResponse;
3232
import org.apache.eventmesh.common.utils.ThreadUtils;
@@ -39,7 +39,6 @@
3939
import java.util.Properties;
4040
import java.util.concurrent.TimeUnit;
4141

42-
4342
import lombok.extern.slf4j.Slf4j;
4443

4544
@Slf4j
@@ -104,7 +103,7 @@ public Optional<EventMeshMessage> handle(final EventMeshMessage msg) throws Exce
104103
}
105104

106105
@Override
107-
public String getProtocolType() {
108-
return EventMeshCommon.EM_MESSAGE_PROTOCOL_NAME;
106+
public EventMeshProtocolType getProtocolType() {
107+
return EventMeshProtocolType.EVENT_MESH_MESSAGE;
109108
}
110109
}

0 commit comments

Comments
 (0)