pandaapo commented on code in PR #4632:
URL: https://github.com/apache/eventmesh/pull/4632#discussion_r1421386965
##########
eventmesh-sdks/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/consumer/SubStreamHandler.java:
##########
@@ -118,26 +116,19 @@ public void onCompleted() {
private CloudEvent buildReplyMessage(final CloudEvent reqMessage, final T
replyMessage) {
final CloudEvent cloudEvent =
EventMeshCloudEventBuilder.buildEventMeshCloudEvent(replyMessage,
clientConfig, listener.getProtocolType());
- SubscriptionReply subscriptionReply =
SubscriptionReply.builder().producerGroup(clientConfig.getConsumerGroup())
- .topic(EventMeshCloudEventUtils.getSubject(cloudEvent))
- .content(EventMeshCloudEventUtils.getDataContent(cloudEvent))
- .seqNum(EventMeshCloudEventUtils.getSeqNum(cloudEvent))
- .uniqueId(EventMeshCloudEventUtils.getUniqueId(cloudEvent))
- .ttl(EventMeshCloudEventUtils.getTtl(cloudEvent)).build();
Map<String, String> prop = new HashMap<>();
Map<String, CloudEventAttributeValue> reqMessageMap =
reqMessage.getAttributesMap();
reqMessageMap.entrySet().forEach(entry -> prop.put(entry.getKey(),
entry.getValue().getCeString()));
Map<String, CloudEventAttributeValue> cloudEventMap =
cloudEvent.getAttributesMap();
cloudEventMap.entrySet().forEach(entry -> prop.put(entry.getKey(),
entry.getValue().getCeString()));
- subscriptionReply.putAllProperties(prop);
- return
CloudEvent.newBuilder(cloudEvent).putAllAttributes(reqMessageMap)
+ return
CloudEvent.newBuilder(cloudEvent).putAllAttributes(reqMessageMap).putAllAttributes(cloudEventMap)
Review Comment:
Doesn't `newBuilder(cloudEvent)` automatically merge the attributes (i.e.,
`cloudEventMap`) of `cloudEvent` here? Additionally, is `prop` object redundant
now?
`newBuilder(cloudEvent)`这一步不是会自动合并`cloudEvent`的attributes(即`cloudEventMap`)吗?另外`prop`对象现在是不是多余的?
##########
eventmesh-sdks/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/consumer/SubStreamHandler.java:
##########
@@ -118,26 +116,19 @@ public void onCompleted() {
private CloudEvent buildReplyMessage(final CloudEvent reqMessage, final T
replyMessage) {
final CloudEvent cloudEvent =
EventMeshCloudEventBuilder.buildEventMeshCloudEvent(replyMessage,
clientConfig, listener.getProtocolType());
- SubscriptionReply subscriptionReply =
SubscriptionReply.builder().producerGroup(clientConfig.getConsumerGroup())
- .topic(EventMeshCloudEventUtils.getSubject(cloudEvent))
- .content(EventMeshCloudEventUtils.getDataContent(cloudEvent))
- .seqNum(EventMeshCloudEventUtils.getSeqNum(cloudEvent))
- .uniqueId(EventMeshCloudEventUtils.getUniqueId(cloudEvent))
- .ttl(EventMeshCloudEventUtils.getTtl(cloudEvent)).build();
Map<String, String> prop = new HashMap<>();
Map<String, CloudEventAttributeValue> reqMessageMap =
reqMessage.getAttributesMap();
reqMessageMap.entrySet().forEach(entry -> prop.put(entry.getKey(),
entry.getValue().getCeString()));
Map<String, CloudEventAttributeValue> cloudEventMap =
cloudEvent.getAttributesMap();
cloudEventMap.entrySet().forEach(entry -> prop.put(entry.getKey(),
entry.getValue().getCeString()));
- subscriptionReply.putAllProperties(prop);
- return
CloudEvent.newBuilder(cloudEvent).putAllAttributes(reqMessageMap)
+ return
CloudEvent.newBuilder(cloudEvent).putAllAttributes(reqMessageMap).putAllAttributes(cloudEventMap)
Review Comment:
Doesn't `newBuilder(cloudEvent)` automatically merge the attributes (i.e.,
`cloudEventMap`) of `cloudEvent` here? Additionally, is `prop` object redundant
now?
`newBuilder(cloudEvent)`这一步不是会自动合并`cloudEvent`的attributes(即`cloudEventMap`)吗?另外`prop`对象现在是不是多余的?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]