This is an automated email from the ASF dual-hosted git repository.
mikexue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/eventmesh.git
The following commit(s) were added to refs/heads/master by this push:
new e5915f7d1 [ISSUE #4204] Repeat the code extraction as a method.
(#4229)
e5915f7d1 is described below
commit e5915f7d1b3c7600642e87cae5d35592775725e0
Author: Fabian Bao <[email protected]>
AuthorDate: Thu Jul 27 15:17:34 2023 +0800
[ISSUE #4204] Repeat the code extraction as a method. (#4229)
* Repeat the code extraction as a method.
* Do some code optimization.[util]
* Do some code optimization.[util]
---
.../tcp/client/task/MessageTransferTask.java | 36 +++++++++++-----------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git
a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/MessageTransferTask.java
b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/MessageTransferTask.java
index 9f5257992..c8742838c 100644
---
a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/MessageTransferTask.java
+++
b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/task/MessageTransferTask.java
@@ -92,7 +92,7 @@ public class MessageTransferTask extends AbstractTask {
//put the context in channel
ctx.channel().attr(AttributeKeys.SERVER_CONTEXT).set(context);
}
- } catch (Throwable ex) {
+ } catch (Exception ex) {
log.warn("upload trace fail in
MessageTransferTask[server-span-start]", ex);
}
@@ -181,25 +181,25 @@ public class MessageTransferTask extends AbstractTask {
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 buildCloudEventWithTimestamps(event,
+ EventMeshConstants.RSP_C2EVENTMESH_TIMESTAMP,
+ EventMeshConstants.RSP_EVENTMESH2MQ_TIMESTAMP, sendTime,
+ 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 buildCloudEventWithTimestamps(event,
+ EventMeshConstants.REQ_C2EVENTMESH_TIMESTAMP,
+ EventMeshConstants.REQ_EVENTMESH2MQ_TIMESTAMP, sendTime,
+ EventMeshConstants.REQ_SEND_EVENTMESH_IP);
}
- return event;
+ }
+
+ private CloudEvent buildCloudEventWithTimestamps(CloudEvent event, String
client2EventMeshTime,
+ String eventMesh2MqTime, long sendTime, String eventMeshIP) {
+ return CloudEventBuilder.from(event)
+ .withExtension(client2EventMeshTime, String.valueOf(startTime))
+ .withExtension(eventMesh2MqTime, String.valueOf(sendTime))
+ .withExtension(eventMeshIP,
eventMeshTCPServer.getEventMeshTCPConfiguration().getEventMeshServerIp())
+ .build();
}
private Command getReplyCmd(Command cmd) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]