You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "L-Gryps (via GitHub)" <gi...@apache.org> on 2025/01/23 09:16:02 UTC

[PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

L-Gryps opened a new pull request, #8581:
URL: https://github.com/apache/seatunnel/pull/8581

   <!--
   
   Thank you for contributing to SeaTunnel! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   ## Contribution Checklist
     - Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/seatunnel/issues).
     - Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
     - Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
   -->
   
   ### Purpose of this pull request
   
   <!-- Describe the purpose of this pull request. For example: This pull request adds checkstyle plugin.-->
   
   
   ### Does this PR introduce _any_ user-facing change?
   
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released SeaTunnel versions or within the unreleased branches such as dev.
   If no, write 'No'.
   If you are adding/modifying connector documents, please follow our new specifications: https://github.com/apache/seatunnel/issues/4544.
   -->
   
   
   ### How was this patch tested?
   
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If you are adding E2E test cases, maybe refer to https://github.com/apache/seatunnel/blob/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-mysql-e2e/src/test/resources/mysqlcdc_to_mysql.conf, here is a good example.
   -->
   
   
   ### Check list
   
   * [ ] If any new Jar binary package adding in your PR, please add License Notice according
     [New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
   * [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
   * [ ] If you are contributing the connector code, please check that the following files are updated:
     1. Update [plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
     2. Update the pom file of [seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
     3. Add ci label in [label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
     4. Add e2e testcase in [seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
     5. Update connector [plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)
   * [ ] Update the [`release-note`](https://github.com/apache/seatunnel/blob/dev/release-note.md).


-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #8581:
URL: https://github.com/apache/seatunnel/pull/8581#discussion_r1982896524


##########
seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineLocalExample.java:
##########
@@ -36,7 +36,7 @@ public class SeaTunnelEngineLocalExample {
 
     public static void main(String[] args)
             throws FileNotFoundException, URISyntaxException, CommandException {
-        String configurePath = args.length > 0 ? args[0] : "/examples/fake_to_console.conf";
+        String configurePath = args.length > 0 ? args[0] : "/examples/realtime-sync.conf";

Review Comment:
   please revert.



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "L-Gryps (via GitHub)" <gi...@apache.org>.
L-Gryps commented on PR #8581:
URL: https://github.com/apache/seatunnel/pull/8581#issuecomment-2789249790

   Please review. @Hisoka-X 


-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "L-Gryps (via GitHub)" <gi...@apache.org>.
L-Gryps commented on code in PR #8581:
URL: https://github.com/apache/seatunnel/pull/8581#discussion_r1984608056


##########
seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineLocalExample.java:
##########
@@ -36,7 +36,7 @@ public class SeaTunnelEngineLocalExample {
 
     public static void main(String[] args)
             throws FileNotFoundException, URISyntaxException, CommandException {
-        String configurePath = args.length > 0 ? args[0] : "/examples/fake_to_console.conf";
+        String configurePath = args.length > 0 ? args[0] : "/examples/realtime-sync.conf";

Review Comment:
   No, this is a redundant commit



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "L-Gryps (via GitHub)" <gi...@apache.org>.
L-Gryps commented on code in PR #8581:
URL: https://github.com/apache/seatunnel/pull/8581#discussion_r1994551424


##########
docs/en/connector-v2/sink/Activemq.md:
##########
@@ -27,19 +24,11 @@ Used to write data to Activemq.
 | disable_timeStamps_by_default       | boolean | no       | -             |
 | use_compression                     | boolean | no       | -             |
 | always_session_async                | boolean | no       | -             |
-| dispatch_async                      | boolean | no       | -             |

Review Comment:
   This parameter applies to consumers, not producers



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "L-Gryps (via GitHub)" <gi...@apache.org>.
L-Gryps commented on code in PR #8581:
URL: https://github.com/apache/seatunnel/pull/8581#discussion_r1948586730


##########
seatunnel-connectors-v2/connector-activemq/src/main/java/org/apache/seatunnel/connectors/seatunnel/activemq/source/ActivemqSourceReader.java:
##########
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.activemq.source;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.serialization.DeserializationSchema;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.source.Collector;
+import org.apache.seatunnel.api.source.SourceReader;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.connectors.seatunnel.activemq.client.ActivemqClient;
+import org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorErrorCode;
+import org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorException;
+import org.apache.seatunnel.connectors.seatunnel.activemq.split.ActivemqSplit;
+import org.apache.seatunnel.format.json.JsonDeserializationSchema;
+
+import lombok.extern.slf4j.Slf4j;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqOptions.QUEUE_NAME;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqSourceOptions.USE_CORRELATION_ID;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorErrorCode.HANDLE_SHUTDOWN_SIGNAL_FAILED;
+
+@Slf4j
+public class ActivemqSourceReader<T> implements SourceReader<T, ActivemqSplit> {
+    protected final Context context;
+    protected final MessageConsumer consumer;
+    protected transient Set<String> correlationIdsProcessedButNotAcknowledged;
+    protected transient List<String> massageIdsProcessedForCurrentSnapshot;
+    protected final SortedMap<Long, List<String>> pendingMassageIdsToCommit;
+    protected final SortedMap<Long, Set<String>> pendingCorrelationIdsToCommit;
+    private final DeserializationSchema<SeaTunnelRow> deserializationSchema;
+    private ActivemqClient activemqClient;
+    private final ReadonlyConfig config;
+
+    public ActivemqSourceReader(
+            DeserializationSchema<SeaTunnelRow> deserializationSchema,
+            Context context,
+            ReadonlyConfig config) {
+        this.pendingMassageIdsToCommit = Collections.synchronizedSortedMap(new TreeMap<>());
+        this.pendingCorrelationIdsToCommit = Collections.synchronizedSortedMap(new TreeMap<>());
+        this.context = context;
+        this.deserializationSchema = deserializationSchema;
+        this.config = config;
+        this.activemqClient = new ActivemqClient(config);
+        this.consumer = activemqClient.getConsumer();
+    }
+
+    @Override
+    public void open() throws Exception {
+        this.correlationIdsProcessedButNotAcknowledged = new HashSet<>();
+        this.massageIdsProcessedForCurrentSnapshot = new ArrayList<>();
+    }
+
+    @Override
+    public void close() throws IOException {
+        try {
+            if (consumer != null) {
+                consumer.close();
+            }
+        } catch (JMSException e) {
+            throw new ActivemqConnectorException(
+                    ActivemqConnectorErrorCode.CLOSE_SESSION_FAILED,
+                    String.format(
+                            "Error while closing AMQ session with  %s", config.get(QUEUE_NAME)));
+        }
+        if (activemqClient != null) {
+            activemqClient.close();
+        }
+    }
+
+    @Override
+    public void pollNext(Collector output) throws Exception {
+        consumer.setMessageListener(

Review Comment:
   Asynchronous processing, does not block, triggers a callback when a message arrives.



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "L-Gryps (via GitHub)" <gi...@apache.org>.
L-Gryps commented on code in PR #8581:
URL: https://github.com/apache/seatunnel/pull/8581#discussion_r2004762072


##########
seatunnel-connectors-v2/connector-activemq/src/main/java/org/apache/seatunnel/connectors/seatunnel/activemq/source/ActivemqSourceReader.java:
##########
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.activemq.source;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.serialization.DeserializationSchema;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.source.Collector;
+import org.apache.seatunnel.api.source.SourceReader;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.connectors.seatunnel.activemq.client.ActivemqClient;
+import org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorErrorCode;
+import org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorException;
+import org.apache.seatunnel.connectors.seatunnel.activemq.split.ActivemqSplit;
+import org.apache.seatunnel.format.json.JsonDeserializationSchema;
+
+import lombok.extern.slf4j.Slf4j;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqOptions.QUEUE_NAME;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqSourceOptions.USE_CORRELATION_ID;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorErrorCode.HANDLE_SHUTDOWN_SIGNAL_FAILED;
+
+@Slf4j
+public class ActivemqSourceReader<T> implements SourceReader<T, ActivemqSplit> {
+    protected final Context context;
+    protected final MessageConsumer consumer;
+    protected transient Set<String> correlationIdsProcessedButNotAcknowledged;
+    protected transient List<String> massageIdsProcessedForCurrentSnapshot;
+    protected final SortedMap<Long, List<String>> pendingMassageIdsToCommit;
+    protected final SortedMap<Long, Set<String>> pendingCorrelationIdsToCommit;
+    private final DeserializationSchema<SeaTunnelRow> deserializationSchema;
+    private ActivemqClient activemqClient;
+    private final ReadonlyConfig config;
+
+    public ActivemqSourceReader(
+            DeserializationSchema<SeaTunnelRow> deserializationSchema,
+            Context context,
+            ReadonlyConfig config) {
+        this.pendingMassageIdsToCommit = Collections.synchronizedSortedMap(new TreeMap<>());
+        this.pendingCorrelationIdsToCommit = Collections.synchronizedSortedMap(new TreeMap<>());
+        this.context = context;
+        this.deserializationSchema = deserializationSchema;
+        this.config = config;
+        this.activemqClient = new ActivemqClient(config);
+        this.consumer = activemqClient.getConsumer();
+    }
+
+    @Override
+    public void open() throws Exception {
+        this.correlationIdsProcessedButNotAcknowledged = new HashSet<>();
+        this.massageIdsProcessedForCurrentSnapshot = new ArrayList<>();
+    }
+
+    @Override
+    public void close() throws IOException {
+        try {
+            if (consumer != null) {
+                consumer.close();
+            }
+        } catch (JMSException e) {
+            throw new ActivemqConnectorException(
+                    ActivemqConnectorErrorCode.CLOSE_SESSION_FAILED,
+                    String.format(
+                            "Error while closing AMQ session with  %s", config.get(QUEUE_NAME)));
+        }
+        if (activemqClient != null) {
+            activemqClient.close();
+        }
+    }
+
+    @Override
+    public void pollNext(Collector output) throws Exception {
+        consumer.setMessageListener(

Review Comment:
   I add blocking queue, thread pool, CompletableFuture to let pollNext blocking until message consume finished, and concurrent processing.  please review.



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #8581: [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector
URL: https://github.com/apache/seatunnel/pull/8581


-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #8581:
URL: https://github.com/apache/seatunnel/pull/8581#discussion_r1982895927


##########
docs/en/connector-v2/sink/Activemq.md:
##########
@@ -27,19 +24,11 @@ Used to write data to Activemq.
 | disable_timeStamps_by_default       | boolean | no       | -             |
 | use_compression                     | boolean | no       | -             |
 | always_session_async                | boolean | no       | -             |
-| dispatch_async                      | boolean | no       | -             |

Review Comment:
   @L-Gryps 



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #8581:
URL: https://github.com/apache/seatunnel/pull/8581#discussion_r1948354065


##########
seatunnel-connectors-v2/connector-activemq/src/main/java/org/apache/seatunnel/connectors/seatunnel/activemq/source/ActivemqSourceReader.java:
##########
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.activemq.source;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.serialization.DeserializationSchema;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.source.Collector;
+import org.apache.seatunnel.api.source.SourceReader;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.connectors.seatunnel.activemq.client.ActivemqClient;
+import org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorErrorCode;
+import org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorException;
+import org.apache.seatunnel.connectors.seatunnel.activemq.split.ActivemqSplit;
+import org.apache.seatunnel.format.json.JsonDeserializationSchema;
+
+import lombok.extern.slf4j.Slf4j;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqOptions.QUEUE_NAME;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqSourceOptions.USE_CORRELATION_ID;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorErrorCode.HANDLE_SHUTDOWN_SIGNAL_FAILED;
+
+@Slf4j
+public class ActivemqSourceReader<T> implements SourceReader<T, ActivemqSplit> {
+    protected final Context context;
+    protected final MessageConsumer consumer;
+    protected transient Set<String> correlationIdsProcessedButNotAcknowledged;
+    protected transient List<String> massageIdsProcessedForCurrentSnapshot;
+    protected final SortedMap<Long, List<String>> pendingMassageIdsToCommit;
+    protected final SortedMap<Long, Set<String>> pendingCorrelationIdsToCommit;
+    private final DeserializationSchema<SeaTunnelRow> deserializationSchema;
+    private ActivemqClient activemqClient;
+    private final ReadonlyConfig config;
+
+    public ActivemqSourceReader(
+            DeserializationSchema<SeaTunnelRow> deserializationSchema,
+            Context context,
+            ReadonlyConfig config) {
+        this.pendingMassageIdsToCommit = Collections.synchronizedSortedMap(new TreeMap<>());
+        this.pendingCorrelationIdsToCommit = Collections.synchronizedSortedMap(new TreeMap<>());
+        this.context = context;
+        this.deserializationSchema = deserializationSchema;
+        this.config = config;
+        this.activemqClient = new ActivemqClient(config);
+        this.consumer = activemqClient.getConsumer();
+    }
+
+    @Override
+    public void open() throws Exception {
+        this.correlationIdsProcessedButNotAcknowledged = new HashSet<>();
+        this.massageIdsProcessedForCurrentSnapshot = new ArrayList<>();
+    }
+
+    @Override
+    public void close() throws IOException {
+        try {
+            if (consumer != null) {
+                consumer.close();
+            }
+        } catch (JMSException e) {
+            throw new ActivemqConnectorException(
+                    ActivemqConnectorErrorCode.CLOSE_SESSION_FAILED,
+                    String.format(
+                            "Error while closing AMQ session with  %s", config.get(QUEUE_NAME)));
+        }
+        if (activemqClient != null) {
+            activemqClient.close();
+        }
+    }
+
+    @Override
+    public void pollNext(Collector output) throws Exception {
+        consumer.setMessageListener(

Review Comment:
   does this method will block until message consume finished?



##########
docs/en/connector-v2/sink/Activemq.md:
##########
@@ -27,19 +24,11 @@ Used to write data to Activemq.
 | disable_timeStamps_by_default       | boolean | no       | -             |
 | use_compression                     | boolean | no       | -             |
 | always_session_async                | boolean | no       | -             |
-| dispatch_async                      | boolean | no       | -             |

Review Comment:
   Why removed this? cc @asapekia



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "L-Gryps (via GitHub)" <gi...@apache.org>.
L-Gryps commented on PR #8581:
URL: https://github.com/apache/seatunnel/pull/8581#issuecomment-2696533210

   Please review. I added message acknowledge mechanism @Hisoka-X 


-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "L-Gryps (via GitHub)" <gi...@apache.org>.
L-Gryps commented on code in PR #8581:
URL: https://github.com/apache/seatunnel/pull/8581#discussion_r1984608056


##########
seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineLocalExample.java:
##########
@@ -36,7 +36,7 @@ public class SeaTunnelEngineLocalExample {
 
     public static void main(String[] args)
             throws FileNotFoundException, URISyntaxException, CommandException {
-        String configurePath = args.length > 0 ? args[0] : "/examples/fake_to_console.conf";
+        String configurePath = args.length > 0 ? args[0] : "/examples/realtime-sync.conf";

Review Comment:
   No, this is a redundant commit



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #8581:
URL: https://github.com/apache/seatunnel/pull/8581#discussion_r1953736250


##########
seatunnel-connectors-v2/connector-activemq/src/main/java/org/apache/seatunnel/connectors/seatunnel/activemq/source/ActivemqSourceReader.java:
##########
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.activemq.source;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.serialization.DeserializationSchema;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.source.Collector;
+import org.apache.seatunnel.api.source.SourceReader;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.connectors.seatunnel.activemq.client.ActivemqClient;
+import org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorErrorCode;
+import org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorException;
+import org.apache.seatunnel.connectors.seatunnel.activemq.split.ActivemqSplit;
+import org.apache.seatunnel.format.json.JsonDeserializationSchema;
+
+import lombok.extern.slf4j.Slf4j;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqOptions.QUEUE_NAME;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqSourceOptions.USE_CORRELATION_ID;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorErrorCode.HANDLE_SHUTDOWN_SIGNAL_FAILED;
+
+@Slf4j
+public class ActivemqSourceReader<T> implements SourceReader<T, ActivemqSplit> {
+    protected final Context context;
+    protected final MessageConsumer consumer;
+    protected transient Set<String> correlationIdsProcessedButNotAcknowledged;
+    protected transient List<String> massageIdsProcessedForCurrentSnapshot;
+    protected final SortedMap<Long, List<String>> pendingMassageIdsToCommit;
+    protected final SortedMap<Long, Set<String>> pendingCorrelationIdsToCommit;
+    private final DeserializationSchema<SeaTunnelRow> deserializationSchema;
+    private ActivemqClient activemqClient;
+    private final ReadonlyConfig config;
+
+    public ActivemqSourceReader(
+            DeserializationSchema<SeaTunnelRow> deserializationSchema,
+            Context context,
+            ReadonlyConfig config) {
+        this.pendingMassageIdsToCommit = Collections.synchronizedSortedMap(new TreeMap<>());
+        this.pendingCorrelationIdsToCommit = Collections.synchronizedSortedMap(new TreeMap<>());
+        this.context = context;
+        this.deserializationSchema = deserializationSchema;
+        this.config = config;
+        this.activemqClient = new ActivemqClient(config);
+        this.consumer = activemqClient.getConsumer();
+    }
+
+    @Override
+    public void open() throws Exception {
+        this.correlationIdsProcessedButNotAcknowledged = new HashSet<>();
+        this.massageIdsProcessedForCurrentSnapshot = new ArrayList<>();
+    }
+
+    @Override
+    public void close() throws IOException {
+        try {
+            if (consumer != null) {
+                consumer.close();
+            }
+        } catch (JMSException e) {
+            throw new ActivemqConnectorException(
+                    ActivemqConnectorErrorCode.CLOSE_SESSION_FAILED,
+                    String.format(
+                            "Error while closing AMQ session with  %s", config.get(QUEUE_NAME)));
+        }
+        if (activemqClient != null) {
+            activemqClient.close();
+        }
+    }
+
+    @Override
+    public void pollNext(Collector output) throws Exception {
+        consumer.setMessageListener(

Review Comment:
   If it is async process, the message will lose sometimes. Because the [no more element evnet](https://github.com/apache/seatunnel/pull/8581/files/a02f2d04ad84550c0f93b94c68fdbe0694fc4e50#diff-751f6c2f551b11669d2b27d51b7ea1399d59bec7aacb05ff71a9fb73cc6590f5R135) will be send to downstream before some messgae.



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "L-Gryps (via GitHub)" <gi...@apache.org>.
L-Gryps commented on code in PR #8581:
URL: https://github.com/apache/seatunnel/pull/8581#discussion_r1984714242


##########
seatunnel-examples/seatunnel-engine-examples/src/main/java/org/apache/seatunnel/example/engine/SeaTunnelEngineLocalExample.java:
##########
@@ -36,7 +36,7 @@ public class SeaTunnelEngineLocalExample {
 
     public static void main(String[] args)
             throws FileNotFoundException, URISyntaxException, CommandException {
-        String configurePath = args.length > 0 ? args[0] : "/examples/fake_to_console.conf";
+        String configurePath = args.length > 0 ? args[0] : "/examples/realtime-sync.conf";

Review Comment:
   recovered



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "L-Gryps (via GitHub)" <gi...@apache.org>.
L-Gryps commented on code in PR #8581:
URL: https://github.com/apache/seatunnel/pull/8581#discussion_r1961142765


##########
seatunnel-connectors-v2/connector-activemq/src/main/java/org/apache/seatunnel/connectors/seatunnel/activemq/source/ActivemqSourceReader.java:
##########
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.activemq.source;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.serialization.DeserializationSchema;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.source.Collector;
+import org.apache.seatunnel.api.source.SourceReader;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.connectors.seatunnel.activemq.client.ActivemqClient;
+import org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorErrorCode;
+import org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorException;
+import org.apache.seatunnel.connectors.seatunnel.activemq.split.ActivemqSplit;
+import org.apache.seatunnel.format.json.JsonDeserializationSchema;
+
+import lombok.extern.slf4j.Slf4j;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqOptions.QUEUE_NAME;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqSourceOptions.USE_CORRELATION_ID;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorErrorCode.HANDLE_SHUTDOWN_SIGNAL_FAILED;
+
+@Slf4j
+public class ActivemqSourceReader<T> implements SourceReader<T, ActivemqSplit> {
+    protected final Context context;
+    protected final MessageConsumer consumer;
+    protected transient Set<String> correlationIdsProcessedButNotAcknowledged;
+    protected transient List<String> massageIdsProcessedForCurrentSnapshot;
+    protected final SortedMap<Long, List<String>> pendingMassageIdsToCommit;
+    protected final SortedMap<Long, Set<String>> pendingCorrelationIdsToCommit;
+    private final DeserializationSchema<SeaTunnelRow> deserializationSchema;
+    private ActivemqClient activemqClient;
+    private final ReadonlyConfig config;
+
+    public ActivemqSourceReader(
+            DeserializationSchema<SeaTunnelRow> deserializationSchema,
+            Context context,
+            ReadonlyConfig config) {
+        this.pendingMassageIdsToCommit = Collections.synchronizedSortedMap(new TreeMap<>());
+        this.pendingCorrelationIdsToCommit = Collections.synchronizedSortedMap(new TreeMap<>());
+        this.context = context;
+        this.deserializationSchema = deserializationSchema;
+        this.config = config;
+        this.activemqClient = new ActivemqClient(config);
+        this.consumer = activemqClient.getConsumer();
+    }
+
+    @Override
+    public void open() throws Exception {
+        this.correlationIdsProcessedButNotAcknowledged = new HashSet<>();
+        this.massageIdsProcessedForCurrentSnapshot = new ArrayList<>();
+    }
+
+    @Override
+    public void close() throws IOException {
+        try {
+            if (consumer != null) {
+                consumer.close();
+            }
+        } catch (JMSException e) {
+            throw new ActivemqConnectorException(
+                    ActivemqConnectorErrorCode.CLOSE_SESSION_FAILED,
+                    String.format(
+                            "Error while closing AMQ session with  %s", config.get(QUEUE_NAME)));
+        }
+        if (activemqClient != null) {
+            activemqClient.close();
+        }
+    }
+
+    @Override
+    public void pollNext(Collector output) throws Exception {
+        consumer.setMessageListener(

Review Comment:
   The Activemq source connector mainly uses the flow mode, which is used for development testing



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #8581:
URL: https://github.com/apache/seatunnel/pull/8581#issuecomment-3193067550

   This pull request has been closed because it has not had recent activity. You could reopen it if you try to continue your work, and anyone who are interested in it are encouraged to continue work on this pull request.


-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "L-Gryps (via GitHub)" <gi...@apache.org>.
L-Gryps commented on code in PR #8581:
URL: https://github.com/apache/seatunnel/pull/8581#discussion_r2004762072


##########
seatunnel-connectors-v2/connector-activemq/src/main/java/org/apache/seatunnel/connectors/seatunnel/activemq/source/ActivemqSourceReader.java:
##########
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.activemq.source;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.serialization.DeserializationSchema;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.source.Collector;
+import org.apache.seatunnel.api.source.SourceReader;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.connectors.seatunnel.activemq.client.ActivemqClient;
+import org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorErrorCode;
+import org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorException;
+import org.apache.seatunnel.connectors.seatunnel.activemq.split.ActivemqSplit;
+import org.apache.seatunnel.format.json.JsonDeserializationSchema;
+
+import lombok.extern.slf4j.Slf4j;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqOptions.QUEUE_NAME;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqSourceOptions.USE_CORRELATION_ID;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorErrorCode.HANDLE_SHUTDOWN_SIGNAL_FAILED;
+
+@Slf4j
+public class ActivemqSourceReader<T> implements SourceReader<T, ActivemqSplit> {
+    protected final Context context;
+    protected final MessageConsumer consumer;
+    protected transient Set<String> correlationIdsProcessedButNotAcknowledged;
+    protected transient List<String> massageIdsProcessedForCurrentSnapshot;
+    protected final SortedMap<Long, List<String>> pendingMassageIdsToCommit;
+    protected final SortedMap<Long, Set<String>> pendingCorrelationIdsToCommit;
+    private final DeserializationSchema<SeaTunnelRow> deserializationSchema;
+    private ActivemqClient activemqClient;
+    private final ReadonlyConfig config;
+
+    public ActivemqSourceReader(
+            DeserializationSchema<SeaTunnelRow> deserializationSchema,
+            Context context,
+            ReadonlyConfig config) {
+        this.pendingMassageIdsToCommit = Collections.synchronizedSortedMap(new TreeMap<>());
+        this.pendingCorrelationIdsToCommit = Collections.synchronizedSortedMap(new TreeMap<>());
+        this.context = context;
+        this.deserializationSchema = deserializationSchema;
+        this.config = config;
+        this.activemqClient = new ActivemqClient(config);
+        this.consumer = activemqClient.getConsumer();
+    }
+
+    @Override
+    public void open() throws Exception {
+        this.correlationIdsProcessedButNotAcknowledged = new HashSet<>();
+        this.massageIdsProcessedForCurrentSnapshot = new ArrayList<>();
+    }
+
+    @Override
+    public void close() throws IOException {
+        try {
+            if (consumer != null) {
+                consumer.close();
+            }
+        } catch (JMSException e) {
+            throw new ActivemqConnectorException(
+                    ActivemqConnectorErrorCode.CLOSE_SESSION_FAILED,
+                    String.format(
+                            "Error while closing AMQ session with  %s", config.get(QUEUE_NAME)));
+        }
+        if (activemqClient != null) {
+            activemqClient.close();
+        }
+    }
+
+    @Override
+    public void pollNext(Collector output) throws Exception {
+        consumer.setMessageListener(

Review Comment:
   I add blocking queue, thread pool, CompletableFuture to let pollNext blocking until message consume finished, and concurrent processing.



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #8581:
URL: https://github.com/apache/seatunnel/pull/8581#discussion_r2000769079


##########
seatunnel-connectors-v2/connector-activemq/src/main/java/org/apache/seatunnel/connectors/seatunnel/activemq/source/ActivemqSourceReader.java:
##########
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.activemq.source;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.serialization.DeserializationSchema;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.source.Collector;
+import org.apache.seatunnel.api.source.SourceReader;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.connectors.seatunnel.activemq.client.ActivemqClient;
+import org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorErrorCode;
+import org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorException;
+import org.apache.seatunnel.connectors.seatunnel.activemq.split.ActivemqSplit;
+import org.apache.seatunnel.format.json.JsonDeserializationSchema;
+
+import lombok.extern.slf4j.Slf4j;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqOptions.QUEUE_NAME;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqSourceOptions.USE_CORRELATION_ID;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorErrorCode.HANDLE_SHUTDOWN_SIGNAL_FAILED;
+
+@Slf4j
+public class ActivemqSourceReader<T> implements SourceReader<T, ActivemqSplit> {
+    protected final Context context;
+    protected final MessageConsumer consumer;
+    protected transient Set<String> correlationIdsProcessedButNotAcknowledged;
+    protected transient List<String> massageIdsProcessedForCurrentSnapshot;
+    protected final SortedMap<Long, List<String>> pendingMassageIdsToCommit;
+    protected final SortedMap<Long, Set<String>> pendingCorrelationIdsToCommit;
+    private final DeserializationSchema<SeaTunnelRow> deserializationSchema;
+    private ActivemqClient activemqClient;
+    private final ReadonlyConfig config;
+
+    public ActivemqSourceReader(
+            DeserializationSchema<SeaTunnelRow> deserializationSchema,
+            Context context,
+            ReadonlyConfig config) {
+        this.pendingMassageIdsToCommit = Collections.synchronizedSortedMap(new TreeMap<>());
+        this.pendingCorrelationIdsToCommit = Collections.synchronizedSortedMap(new TreeMap<>());
+        this.context = context;
+        this.deserializationSchema = deserializationSchema;
+        this.config = config;
+        this.activemqClient = new ActivemqClient(config);
+        this.consumer = activemqClient.getConsumer();
+    }
+
+    @Override
+    public void open() throws Exception {
+        this.correlationIdsProcessedButNotAcknowledged = new HashSet<>();
+        this.massageIdsProcessedForCurrentSnapshot = new ArrayList<>();
+    }
+
+    @Override
+    public void close() throws IOException {
+        try {
+            if (consumer != null) {
+                consumer.close();
+            }
+        } catch (JMSException e) {
+            throw new ActivemqConnectorException(
+                    ActivemqConnectorErrorCode.CLOSE_SESSION_FAILED,
+                    String.format(
+                            "Error while closing AMQ session with  %s", config.get(QUEUE_NAME)));
+        }
+        if (activemqClient != null) {
+            activemqClient.close();
+        }
+    }
+
+    @Override
+    public void pollNext(Collector output) throws Exception {
+        consumer.setMessageListener(

Review Comment:
   This will break our interface definition. After the `pollNext` method returns, no data should continue to be generated. I think we should introduce `CompletableFuture` to let `pollNext` block until message consume finished. Please refer https://github.com/apache/seatunnel/blob/a85fce4d54afdee389ffbc0dff3ddca94b8137bc/seatunnel-connectors-v2/connector-rocketmq/src/main/java/org/apache/seatunnel/connectors/seatunnel/rocketmq/source/RocketMqSourceReader.java#L116



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #8581:
URL: https://github.com/apache/seatunnel/pull/8581#discussion_r1942209712


##########
seatunnel-connectors-v2/connector-activemq/src/main/java/org/apache/seatunnel/connectors/seatunnel/activemq/sink/ActivemqSinkFactory.java:
##########
@@ -72,9 +66,4 @@ public OptionRule optionRule() {
                         WARN_ABOUT_UNSTARTED_CONNECTION_TIMEOUT)
                 .build();
     }
-
-    @Override
-    public TableSink createSink(TableSinkFactoryContext context) {
-        return () -> new ActivemqSink(context.getOptions(), context.getCatalogTable());
-    }

Review Comment:
   Please use `createSink` to create new instance. Do not use SPI in https://github.com/apache/seatunnel/pull/8581/files#diff-5e51ad244c8ce82135d5edbc4f9a925492b1e479c25f45f8ae722c36bd09edebR45



##########
seatunnel-connectors-v2/connector-activemq/src/main/java/org/apache/seatunnel/connectors/seatunnel/activemq/source/ActivemqSource.java:
##########
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.activemq.source;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import org.apache.seatunnel.api.common.JobContext;
+import org.apache.seatunnel.api.common.PrepareFailException;
+import org.apache.seatunnel.api.common.SeaTunnelAPIErrorCode;
+import org.apache.seatunnel.api.serialization.DeserializationSchema;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.source.SeaTunnelSource;
+import org.apache.seatunnel.api.source.SourceReader;
+import org.apache.seatunnel.api.source.SourceSplitEnumerator;
+import org.apache.seatunnel.api.source.SupportParallelism;
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.catalog.CatalogTableUtil;
+import org.apache.seatunnel.api.table.catalog.schema.TableSchemaOptions;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.common.config.CheckConfigUtil;
+import org.apache.seatunnel.common.config.CheckResult;
+import org.apache.seatunnel.common.constants.JobMode;
+import org.apache.seatunnel.common.constants.PluginType;
+import org.apache.seatunnel.common.exception.CommonErrorCodeDeprecated;
+import org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqConfig;
+import org.apache.seatunnel.connectors.seatunnel.activemq.config.SchemaFormat;
+import org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorException;
+import org.apache.seatunnel.connectors.seatunnel.activemq.split.ActivemqSplit;
+import org.apache.seatunnel.connectors.seatunnel.activemq.split.ActivemqSplitEnumeratorState;
+import org.apache.seatunnel.format.json.JsonDeserializationSchema;
+import org.apache.seatunnel.format.json.exception.SeaTunnelJsonFormatException;
+import org.apache.seatunnel.format.text.TextDeserializationSchema;
+
+import com.google.auto.service.AutoService;
+
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqConfig.FIELD_DELIMITER;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqConfig.FORMAT;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqConfig.QUEUE_NAME;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqConfig.SCHEMA;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqConfig.URI;
+
+@AutoService(SeaTunnelSource.class)

Review Comment:
   ditto.



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "L-Gryps (via GitHub)" <gi...@apache.org>.
L-Gryps commented on code in PR #8581:
URL: https://github.com/apache/seatunnel/pull/8581#discussion_r1961142984


##########
seatunnel-connectors-v2/connector-activemq/src/main/java/org/apache/seatunnel/connectors/seatunnel/activemq/source/ActivemqSourceReader.java:
##########
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.activemq.source;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.serialization.DeserializationSchema;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.source.Collector;
+import org.apache.seatunnel.api.source.SourceReader;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.connectors.seatunnel.activemq.client.ActivemqClient;
+import org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorErrorCode;
+import org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorException;
+import org.apache.seatunnel.connectors.seatunnel.activemq.split.ActivemqSplit;
+import org.apache.seatunnel.format.json.JsonDeserializationSchema;
+
+import lombok.extern.slf4j.Slf4j;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqOptions.QUEUE_NAME;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqSourceOptions.USE_CORRELATION_ID;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorErrorCode.HANDLE_SHUTDOWN_SIGNAL_FAILED;
+
+@Slf4j
+public class ActivemqSourceReader<T> implements SourceReader<T, ActivemqSplit> {
+    protected final Context context;
+    protected final MessageConsumer consumer;
+    protected transient Set<String> correlationIdsProcessedButNotAcknowledged;
+    protected transient List<String> massageIdsProcessedForCurrentSnapshot;
+    protected final SortedMap<Long, List<String>> pendingMassageIdsToCommit;
+    protected final SortedMap<Long, Set<String>> pendingCorrelationIdsToCommit;
+    private final DeserializationSchema<SeaTunnelRow> deserializationSchema;
+    private ActivemqClient activemqClient;
+    private final ReadonlyConfig config;
+
+    public ActivemqSourceReader(
+            DeserializationSchema<SeaTunnelRow> deserializationSchema,
+            Context context,
+            ReadonlyConfig config) {
+        this.pendingMassageIdsToCommit = Collections.synchronizedSortedMap(new TreeMap<>());
+        this.pendingCorrelationIdsToCommit = Collections.synchronizedSortedMap(new TreeMap<>());
+        this.context = context;
+        this.deserializationSchema = deserializationSchema;
+        this.config = config;
+        this.activemqClient = new ActivemqClient(config);
+        this.consumer = activemqClient.getConsumer();
+    }
+
+    @Override
+    public void open() throws Exception {
+        this.correlationIdsProcessedButNotAcknowledged = new HashSet<>();
+        this.massageIdsProcessedForCurrentSnapshot = new ArrayList<>();
+    }
+
+    @Override
+    public void close() throws IOException {
+        try {
+            if (consumer != null) {
+                consumer.close();
+            }
+        } catch (JMSException e) {
+            throw new ActivemqConnectorException(
+                    ActivemqConnectorErrorCode.CLOSE_SESSION_FAILED,
+                    String.format(
+                            "Error while closing AMQ session with  %s", config.get(QUEUE_NAME)));
+        }
+        if (activemqClient != null) {
+            activemqClient.close();
+        }
+    }
+
+    @Override
+    public void pollNext(Collector output) throws Exception {
+        consumer.setMessageListener(

Review Comment:
   Any better suggestions



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "L-Gryps (via GitHub)" <gi...@apache.org>.
L-Gryps commented on code in PR #8581:
URL: https://github.com/apache/seatunnel/pull/8581#discussion_r1946193698


##########
seatunnel-connectors-v2/connector-activemq/src/main/java/org/apache/seatunnel/connectors/seatunnel/activemq/source/ActivemqSource.java:
##########
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.activemq.source;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import org.apache.seatunnel.api.common.JobContext;
+import org.apache.seatunnel.api.common.PrepareFailException;
+import org.apache.seatunnel.api.common.SeaTunnelAPIErrorCode;
+import org.apache.seatunnel.api.serialization.DeserializationSchema;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.source.SeaTunnelSource;
+import org.apache.seatunnel.api.source.SourceReader;
+import org.apache.seatunnel.api.source.SourceSplitEnumerator;
+import org.apache.seatunnel.api.source.SupportParallelism;
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.catalog.CatalogTableUtil;
+import org.apache.seatunnel.api.table.catalog.schema.TableSchemaOptions;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.common.config.CheckConfigUtil;
+import org.apache.seatunnel.common.config.CheckResult;
+import org.apache.seatunnel.common.constants.JobMode;
+import org.apache.seatunnel.common.constants.PluginType;
+import org.apache.seatunnel.common.exception.CommonErrorCodeDeprecated;
+import org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqConfig;
+import org.apache.seatunnel.connectors.seatunnel.activemq.config.SchemaFormat;
+import org.apache.seatunnel.connectors.seatunnel.activemq.exception.ActivemqConnectorException;
+import org.apache.seatunnel.connectors.seatunnel.activemq.split.ActivemqSplit;
+import org.apache.seatunnel.connectors.seatunnel.activemq.split.ActivemqSplitEnumeratorState;
+import org.apache.seatunnel.format.json.JsonDeserializationSchema;
+import org.apache.seatunnel.format.json.exception.SeaTunnelJsonFormatException;
+import org.apache.seatunnel.format.text.TextDeserializationSchema;
+
+import com.google.auto.service.AutoService;
+
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqConfig.FIELD_DELIMITER;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqConfig.FORMAT;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqConfig.QUEUE_NAME;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqConfig.SCHEMA;
+import static org.apache.seatunnel.connectors.seatunnel.activemq.config.ActivemqConfig.URI;
+
+@AutoService(SeaTunnelSource.class)

Review Comment:
   Please review. I have made corresponding modifications



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


Re: [PR] [feature][connectors-v2][ActiveMQ] add ActiveMQ source connector [seatunnel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #8581:
URL: https://github.com/apache/seatunnel/pull/8581#issuecomment-3166228611

   This pull request has been automatically marked as stale because it has not had recent activity for 120 days. It will be closed in 7 days if no further activity occurs.


-- 
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: commits-unsubscribe@seatunnel.apache.org

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