You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/08/28 07:06:55 UTC

[GitHub] [rocketmq-connect] Oliverwqcwrw opened a new pull request, #291: [ISSUE #290] activemq source connector adapt to new api

Oliverwqcwrw opened a new pull request, #291:
URL: https://github.com/apache/rocketmq-connect/pull/291

   ## What is the purpose of the change
   
   Close #290 
   
   ## Brief changelog
   
   activemq source connector adapt to new api
   
   ## Verifying this change
   
   XXXX
   
   Follow this checklist to help us incorporate your contribution quickly and easily. Notice, `it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR`.
   
   - [x] Make sure there is a [Github issue](https://github.com/apache/rocketmq-connect/issues) filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue. 
   - [x] Format the pull request title like `[ISSUE #123] Fix UnknownException when host config not exist`. Each commit in the pull request should have a meaningful subject line and body.
   - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [x] Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in [test module](https://github.com/apache/rocketmq/tree/master/test).
   - [x] Run `mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle` to make sure basic checks pass. Run `mvn clean install -DskipITs` to make sure unit-test pass. Run `mvn clean test-compile failsafe:integration-test`  to make sure integration-test pass.
   - [ ] If this contribution is large, please file an [Apache Individual Contributor License Agreement](http://www.apache.org/licenses/#clas).
   


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-connect] odbozhou commented on a diff in pull request #291: [ISSUE #290] activemq source connector adapt to new api

Posted by GitBox <gi...@apache.org>.
odbozhou commented on code in PR #291:
URL: https://github.com/apache/rocketmq-connect/pull/291#discussion_r971579495


##########
connectors/rocketmq-connect-activemq/src/main/java/org/apache/rocketmq/connect/activemq/connector/ActivemqSourceTask.java:
##########
@@ -131,11 +118,52 @@ public ByteBuffer getMessageContent(Message message) throws JMSException {
             while ((i = streamMessage.readBytes(by)) != -1) {
                 bis.write(by, 0, i);
             }
-            data = bis.toByteArray();
+            data = bis.toString();
         } else {
             // The exception is printed and does not need to be written as a DataConnectException
             throw new RuntimeException("message type exception");
         }
-        return ByteBuffer.wrap(data);
+        return data;
+    }
+
+    private ConnectRecord message2ConnectRecord(Message message) throws JMSException {
+        Schema schema = SchemaBuilder.struct().name("activemq").build();
+        final List<Field> fields = buildFields();
+        schema.setFields(fields);
+        return new ConnectRecord(buildRecordPartition(),
+            buildRecordOffset(),
+            System.currentTimeMillis(),
+            schema,
+            buildPayLoad(fields, message, schema));
+    }
+
+    private RecordOffset buildRecordOffset()  {
+        Map<String, Long> offsetMap = new HashMap<>();
+        RecordOffset recordOffset = new RecordOffset(offsetMap);

Review Comment:
   RecordOffset value is empty map?



##########
connectors/rocketmq-connect-activemq/src/main/java/org/apache/rocketmq/connect/activemq/connector/ActivemqSourceTask.java:
##########
@@ -131,11 +118,52 @@ public ByteBuffer getMessageContent(Message message) throws JMSException {
             while ((i = streamMessage.readBytes(by)) != -1) {
                 bis.write(by, 0, i);
             }
-            data = bis.toByteArray();
+            data = bis.toString();
         } else {
             // The exception is printed and does not need to be written as a DataConnectException
             throw new RuntimeException("message type exception");
         }
-        return ByteBuffer.wrap(data);
+        return data;
+    }
+
+    private ConnectRecord message2ConnectRecord(Message message) throws JMSException {
+        Schema schema = SchemaBuilder.struct().name("activemq").build();
+        final List<Field> fields = buildFields();
+        schema.setFields(fields);
+        return new ConnectRecord(buildRecordPartition(),
+            buildRecordOffset(),
+            System.currentTimeMillis(),
+            schema,
+            buildPayLoad(fields, message, schema));
+    }
+
+    private RecordOffset buildRecordOffset()  {
+        Map<String, Long> offsetMap = new HashMap<>();
+        RecordOffset recordOffset = new RecordOffset(offsetMap);
+        return recordOffset;
+    }
+
+    private RecordPartition buildRecordPartition() {
+        Map<String, String> partitionMap = new HashMap<>();
+        partitionMap.put("partition", "defaultPartition");
+        RecordPartition  recordPartition = new RecordPartition(partitionMap);
+        return recordPartition;
+    }
+
+    private List<Field> buildFields() {
+        final Schema stringSchema = SchemaBuilder.string().build();
+        List<Field> fields = new ArrayList<>();
+        fields.add(new Field(0, Config.DESTINATION_NAME, stringSchema));
+        fields.add(new Field(1, Config.DESTINATION_TYPE, stringSchema));
+        fields.add(new Field(2, Config.MESSAGE, stringSchema));
+        return fields;
+    }
+
+    private Struct buildPayLoad(List<Field> fields, Message message, Schema schema) throws JMSException {
+        Struct payLoad = new Struct(schema);
+        payLoad.put(fields.get(0), config.getDestinationName());
+        payLoad.put(fields.get(1), config.getDestinationType());
+        payLoad.put(fields.get(2), getMessageContent(message));

Review Comment:
   Whether the payload can only put the message data, the extra information can be put in the extension field, it will be more general



-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-connect] Oliverwqcwrw commented on a diff in pull request #291: [ISSUE #290] activemq source connector adapt to new api

Posted by GitBox <gi...@apache.org>.
Oliverwqcwrw commented on code in PR #291:
URL: https://github.com/apache/rocketmq-connect/pull/291#discussion_r973685036


##########
connectors/rocketmq-connect-activemq/src/main/java/org/apache/rocketmq/connect/activemq/connector/ActivemqSourceTask.java:
##########
@@ -131,11 +118,52 @@ public ByteBuffer getMessageContent(Message message) throws JMSException {
             while ((i = streamMessage.readBytes(by)) != -1) {
                 bis.write(by, 0, i);
             }
-            data = bis.toByteArray();
+            data = bis.toString();
         } else {
             // The exception is printed and does not need to be written as a DataConnectException
             throw new RuntimeException("message type exception");
         }
-        return ByteBuffer.wrap(data);
+        return data;
+    }
+
+    private ConnectRecord message2ConnectRecord(Message message) throws JMSException {
+        Schema schema = SchemaBuilder.struct().name("activemq").build();
+        final List<Field> fields = buildFields();
+        schema.setFields(fields);
+        return new ConnectRecord(buildRecordPartition(),
+            buildRecordOffset(),
+            System.currentTimeMillis(),
+            schema,
+            buildPayLoad(fields, message, schema));
+    }
+
+    private RecordOffset buildRecordOffset()  {
+        Map<String, Long> offsetMap = new HashMap<>();
+        RecordOffset recordOffset = new RecordOffset(offsetMap);

Review Comment:
   I have  solved it



-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-connect] Oliverwqcwrw commented on a diff in pull request #291: [ISSUE #290] activemq source connector adapt to new api

Posted by GitBox <gi...@apache.org>.
Oliverwqcwrw commented on code in PR #291:
URL: https://github.com/apache/rocketmq-connect/pull/291#discussion_r972002729


##########
connectors/rocketmq-connect-activemq/src/main/java/org/apache/rocketmq/connect/activemq/connector/ActivemqSourceTask.java:
##########
@@ -131,11 +118,52 @@ public ByteBuffer getMessageContent(Message message) throws JMSException {
             while ((i = streamMessage.readBytes(by)) != -1) {
                 bis.write(by, 0, i);
             }
-            data = bis.toByteArray();
+            data = bis.toString();
         } else {
             // The exception is printed and does not need to be written as a DataConnectException
             throw new RuntimeException("message type exception");
         }
-        return ByteBuffer.wrap(data);
+        return data;
+    }
+
+    private ConnectRecord message2ConnectRecord(Message message) throws JMSException {
+        Schema schema = SchemaBuilder.struct().name("activemq").build();
+        final List<Field> fields = buildFields();
+        schema.setFields(fields);
+        return new ConnectRecord(buildRecordPartition(),
+            buildRecordOffset(),
+            System.currentTimeMillis(),
+            schema,
+            buildPayLoad(fields, message, schema));
+    }
+
+    private RecordOffset buildRecordOffset()  {
+        Map<String, Long> offsetMap = new HashMap<>();
+        RecordOffset recordOffset = new RecordOffset(offsetMap);

Review Comment:
   Hello @odbozhou ,
   This is set to empty for two reasons
   
   - The previous version does not set offset
   - Data migration through consuming messages does not require position
   
   Please let me know if i  am  missing something



-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-connect] odbozhou merged pull request #291: [ISSUE #290] activemq source connector adapt to new api

Posted by GitBox <gi...@apache.org>.
odbozhou merged PR #291:
URL: https://github.com/apache/rocketmq-connect/pull/291


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org