[
https://issues.apache.org/jira/browse/ARTEMIS-3285?focusedWorklogId=594179&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-594179
]
ASF GitHub Bot logged work on ARTEMIS-3285:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 10/May/21 18:57
Start Date: 10/May/21 18:57
Worklog Time Spent: 10m
Work Description: jbertram commented on a change in pull request #3569:
URL: https://github.com/apache/activemq-artemis/pull/3569#discussion_r629608522
##########
File path:
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSNonDestructiveTest.java
##########
@@ -588,4 +594,82 @@ private void sendLVQTombstone(ConnectionSupplier
producerConnectionSupplier, Str
producer.send(message1, javax.jms.Message.DEFAULT_DELIVERY_MODE,
javax.jms.Message.DEFAULT_PRIORITY, tombstoneTimeToLive);
}
}
+
+ @Test
+ public void testMultipleLastValuesCore() throws Exception {
+ testMultipleLastValues(CoreConnection);
+ }
+
+ @Test
+ public void testMultipleLastValuesAMQP() throws Exception {
+ testMultipleLastValues(AMQPConnection);
+ }
+
+ private void testMultipleLastValues(ConnectionSupplier connectionSupplier)
throws Exception {
+ HashMap<String, List<String>> results = new HashMap<>();
+ results.put("0", new ArrayList<>());
+ results.put("1", new ArrayList<>());
+ results.put("2", new ArrayList<>());
+ HashMap<String, Integer> dups = new HashMap<>();
+
+ try (Connection connection = connectionSupplier.createConnection();
+ Connection connection2 = connectionSupplier.createConnection()) {
+ Session session = connection.createSession(false,
Session.CLIENT_ACKNOWLEDGE);
+ Session session2 = connection2.createSession(false,
Session.CLIENT_ACKNOWLEDGE);
+
+ Queue queue = session.createQueue(NON_DESTRUCTIVE_LVQ_QUEUE_NAME);
+
+ MessageProducer producer = session2.createProducer(queue);
+ MessageConsumer consumer = session.createConsumer(queue);
+ connection.start();
+
+ Thread t = new Thread(() -> {
+ for (int i = 0; i < 100; i++) {
+ String lastval = "" + (i % 3);
+ try {
+ TextMessage message = session2.createTextMessage();
+ message.setText("" + i);
+ message.setStringProperty("data", "" + i);
+ message.setStringProperty("lastval", lastval);
+
message.setStringProperty(Message.HDR_LAST_VALUE_NAME.toString(), lastval);
+ producer.send(message);
+ } catch (JMSException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+
+ t.start();
+ int received = 0;
+ while (true) {
+ TextMessage tm = (TextMessage) consumer.receive(500);
+ if (tm == null) {
+ break;
+ }
+ System.out.println("Received: " + tm.getStringProperty("data") +
"; total: " + ++received);
Review comment:
Done.
##########
File path:
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSNonDestructiveTest.java
##########
@@ -588,4 +594,82 @@ private void sendLVQTombstone(ConnectionSupplier
producerConnectionSupplier, Str
producer.send(message1, javax.jms.Message.DEFAULT_DELIVERY_MODE,
javax.jms.Message.DEFAULT_PRIORITY, tombstoneTimeToLive);
}
}
+
+ @Test
+ public void testMultipleLastValuesCore() throws Exception {
+ testMultipleLastValues(CoreConnection);
+ }
+
+ @Test
+ public void testMultipleLastValuesAMQP() throws Exception {
+ testMultipleLastValues(AMQPConnection);
+ }
+
+ private void testMultipleLastValues(ConnectionSupplier connectionSupplier)
throws Exception {
+ HashMap<String, List<String>> results = new HashMap<>();
+ results.put("0", new ArrayList<>());
+ results.put("1", new ArrayList<>());
+ results.put("2", new ArrayList<>());
+ HashMap<String, Integer> dups = new HashMap<>();
+
+ try (Connection connection = connectionSupplier.createConnection();
+ Connection connection2 = connectionSupplier.createConnection()) {
+ Session session = connection.createSession(false,
Session.CLIENT_ACKNOWLEDGE);
+ Session session2 = connection2.createSession(false,
Session.CLIENT_ACKNOWLEDGE);
+
+ Queue queue = session.createQueue(NON_DESTRUCTIVE_LVQ_QUEUE_NAME);
+
+ MessageProducer producer = session2.createProducer(queue);
+ MessageConsumer consumer = session.createConsumer(queue);
+ connection.start();
+
+ Thread t = new Thread(() -> {
+ for (int i = 0; i < 100; i++) {
+ String lastval = "" + (i % 3);
+ try {
+ TextMessage message = session2.createTextMessage();
+ message.setText("" + i);
+ message.setStringProperty("data", "" + i);
+ message.setStringProperty("lastval", lastval);
+
message.setStringProperty(Message.HDR_LAST_VALUE_NAME.toString(), lastval);
+ producer.send(message);
+ } catch (JMSException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+
+ t.start();
+ int received = 0;
+ while (true) {
+ TextMessage tm = (TextMessage) consumer.receive(500);
+ if (tm == null) {
+ break;
+ }
+ System.out.println("Received: " + tm.getStringProperty("data") +
"; total: " + ++received);
+ results.get(tm.getStringProperty("lastval")).add(tm.getText());
+ tm.acknowledge();
+ }
+ }
+ for (Map.Entry<String, List<String>> entry : results.entrySet()) {
+ System.out.print("Messages received with lastval=" + entry.getKey() +
" (");
+ for (String s : entry.getValue()) {
+ int occurrences = Collections.frequency(entry.getValue(), s);
+ if (occurrences > 1 && !dups.containsValue(Integer.parseInt(s))) {
+ dups.put(s, occurrences);
+ }
+ System.out.print(s + ",");
Review comment:
Done.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 594179)
Time Spent: 1h 10m (was: 1h)
> Potential duplicate messages with LVQ + non-destructive
> -------------------------------------------------------
>
> Key: ARTEMIS-3285
> URL: https://issues.apache.org/jira/browse/ARTEMIS-3285
> Project: ActiveMQ Artemis
> Issue Type: Bug
> Reporter: Justin Bertram
> Assignee: Justin Bertram
> Priority: Major
> Time Spent: 1h 10m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)