lrhkobe commented on code in PR #4229:
URL: https://github.com/apache/eventmesh/pull/4229#discussion_r1268077953


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/MessageTransferTask.java:
##########
@@ -181,25 +181,20 @@ public void run() {
 
     private CloudEvent addTimestamp(CloudEvent event, Command cmd, long 
sendTime) {
         if (cmd == RESPONSE_TO_SERVER) {
-            event = CloudEventBuilder.from(event)
-                .withExtension(EventMeshConstants.RSP_C2EVENTMESH_TIMESTAMP,
-                    String.valueOf(startTime))
-                .withExtension(EventMeshConstants.RSP_EVENTMESH2MQ_TIMESTAMP,
-                    String.valueOf(sendTime))
-                .withExtension(EventMeshConstants.RSP_SEND_EVENTMESH_IP,
-                    
eventMeshTCPServer.getEventMeshTCPConfiguration().getEventMeshServerIp())
-                .build();
+            return getCloudEvent(event, sendTime, 
EventMeshConstants.RSP_C2EVENTMESH_TIMESTAMP, 
EventMeshConstants.RSP_EVENTMESH2MQ_TIMESTAMP,
+                EventMeshConstants.RSP_SEND_EVENTMESH_IP);
         } else {
-            event = CloudEventBuilder.from(event)
-                .withExtension(EventMeshConstants.REQ_C2EVENTMESH_TIMESTAMP,
-                    String.valueOf(startTime))
-                .withExtension(EventMeshConstants.REQ_EVENTMESH2MQ_TIMESTAMP,
-                    String.valueOf(sendTime))
-                .withExtension(EventMeshConstants.REQ_SEND_EVENTMESH_IP,
-                    
eventMeshTCPServer.getEventMeshTCPConfiguration().getEventMeshServerIp())
-                .build();
+            return getCloudEvent(event, sendTime, 
EventMeshConstants.REQ_C2EVENTMESH_TIMESTAMP, 
EventMeshConstants.REQ_EVENTMESH2MQ_TIMESTAMP,
+                EventMeshConstants.REQ_SEND_EVENTMESH_IP);

Review Comment:
   I prefer to keep the previous way.
   Because the readability of this method `private CloudEvent 
getCloudEvent(CloudEvent event, long sendTime, String times, String mq, String 
ip)`  is not good.
   
   Such as:
   ```
    CloudEventBuilder.from(event)
               .withExtension(times, String.valueOf(startTime))
               .withExtension(mq, String.valueOf(sendTime))
   ```
   The parameter ( `times` and `mq` ) and the value passed in  seems not match.



-- 
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]

Reply via email to