pandaapo commented on code in PR #4569:
URL: https://github.com/apache/eventmesh/pull/4569#discussion_r1398416343


##########
eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java:
##########
@@ -233,16 +233,24 @@ private void startConnector() throws Exception {
     }
 
     private CloudEvent convertRecordToEvent(ConnectRecord connectRecord) {
+        CloudEventBuilder cloudEventBuilder = CloudEventBuilder.v1();
+
+        cloudEventBuilder.withId(UUID.randomUUID().toString())
+                .withSubject(config.getPubSubConfig().getSubject())
+                .withSource(URI.create("/"))
+                .withDataContentType("application/cloudevents+json")
+                .withType(CLOUD_EVENTS_PROTOCOL_NAME)
+                
.withData(Objects.requireNonNull(JsonUtils.toJSONString(connectRecord.getData())).getBytes(StandardCharsets.UTF_8))
+                .withExtension("ttl", 10000);
+
+        for (String key : connectRecord.getExtensions().keySet()) {
+            Object extension = connectRecord.getExtensionObj(key);
+            if (extension instanceof String) {
+                cloudEventBuilder.withExtension(key, extension.toString());

Review Comment:
   Should this be the `(String) extension`, not `extension.toString()`?  
Additionally, in order to make this method more versatile, could you add all 
the types supported by `CloudEventBuilder#withExtension(String , )`?
   
   这里应该是`(String) 
extension`,而不是`extension.toString()`吧?另外,为了让该方法更通用,是不是可以把`CloudEventBuilder#withExtension(String
 , )`支持的几种类型全部加上去?



##########
eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java:
##########
@@ -233,16 +233,24 @@ private void startConnector() throws Exception {
     }
 
     private CloudEvent convertRecordToEvent(ConnectRecord connectRecord) {
+        CloudEventBuilder cloudEventBuilder = CloudEventBuilder.v1();
+
+        cloudEventBuilder.withId(UUID.randomUUID().toString())
+                .withSubject(config.getPubSubConfig().getSubject())
+                .withSource(URI.create("/"))
+                .withDataContentType("application/cloudevents+json")
+                .withType(CLOUD_EVENTS_PROTOCOL_NAME)
+                
.withData(Objects.requireNonNull(JsonUtils.toJSONString(connectRecord.getData())).getBytes(StandardCharsets.UTF_8))
+                .withExtension("ttl", 10000);
+
+        for (String key : connectRecord.getExtensions().keySet()) {
+            Object extension = connectRecord.getExtensionObj(key);
+            if (extension instanceof String) {
+                cloudEventBuilder.withExtension(key, extension.toString());

Review Comment:
   Should this be the `(String) extension`, not `extension.toString()`?  
Additionally, in order to make this method more versatile, could you add all 
the types supported by `CloudEventBuilder#withExtension(String , )`?
   
   这里应该是`(String) 
extension`,而不是`extension.toString()`吧?另外,为了让该方法更通用,是不是可以把`CloudEventBuilder#withExtension(String
 , )`支持的几种类型全部加上去?



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