mxsm commented on code in PR #4632:
URL: https://github.com/apache/eventmesh/pull/4632#discussion_r1421395460
##########
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`对象现在是不是多余的?
Here, it is guaranteed that if there are identical properties between the
returned message and the consumed message, the properties of the consumed
message will be used. At the same time, I compared the version before
optimization. It is also a similar operation. If the properties do not need to
be overwritten, this step is not required. I keep it consistent with the
version before GRPC optimization.
##########
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`对象现在是不是多余的?
Here, it is guaranteed that if there are identical properties between the
returned message and the consumed message, the properties of the consumed
message will be used. At the same time, I compared the version before
optimization. It is also a similar operation. If the properties do not need to
be overwritten, this step is not required. I keep it consistent with the
version before GRPC optimization.
--
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]