franz1981 commented on a change in pull request #3927:
URL: https://github.com/apache/activemq-artemis/pull/3927#discussion_r791719029
##########
File path:
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/RedeliveryPolicyTest.java
##########
@@ -355,6 +359,53 @@ public void testMaximumRedeliveryDelay() throws Exception {
assertTrue(policy.getNextRedeliveryDelay(Long.MAX_VALUE) == 1000);
}
+ /**
+ * @throws Exception
+ */
+ @Test
+ public void testRedeliveryRefCleanup() throws Exception {
+
+ // Receive a message with the JMS API
+ RedeliveryPolicy policy = connection.getRedeliveryPolicy();
+ policy.setUseExponentialBackOff(false);
+ policy.setMaximumRedeliveries(-1);
+ policy.setRedeliveryDelay(50);
+
+ connection.start();
+ Session pSession = connection.createSession(true,
Session.AUTO_ACKNOWLEDGE);
+ Session cSession = connection.createSession(true,
Session.AUTO_ACKNOWLEDGE);
+ ActiveMQQueue destination = new ActiveMQQueue("TEST");
+ this.makeSureCoreQueueExist("TEST");
+ MessageProducer producer = pSession.createProducer(destination);
+ MessageConsumer consumer = cSession.createConsumer(destination);
+
+ TextMessage m;
+
+ for (int i = 0; i < 5; ++i) {
+ producer.send(pSession.createTextMessage("MessageText"));
+ pSession.commit();
+ m = (TextMessage) consumer.receive(2000);
+ assertNotNull(m);
+ cSession.rollback();
+ m = (TextMessage) consumer.receive(2000);
+ assertNotNull(m);
+ cSession.commit();
+ }
+ ServerConsumer serverConsumer = null;
+ for (ServerSession session : server.getSessions()) {
+ for (ServerConsumer sessionConsumer : session.getServerConsumers()) {
+ if (sessionConsumer.getQueue().getName().toString() == "TEST") {
+ serverConsumer = sessionConsumer;
+ }
+ }
+ }
+ AMQConsumer amqConsumer = (AMQConsumer) serverConsumer.getProtocolData();
Review comment:
At this point it would be better to be able to query `AMQConsumer` re
rolledbackMessageRefs directly, exposing an ad-hoc method used just for testing
purposes
##########
File path:
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/RedeliveryPolicyTest.java
##########
@@ -355,6 +359,53 @@ public void testMaximumRedeliveryDelay() throws Exception {
assertTrue(policy.getNextRedeliveryDelay(Long.MAX_VALUE) == 1000);
}
+ /**
+ * @throws Exception
+ */
+ @Test
+ public void testRedeliveryRefCleanup() throws Exception {
+
+ // Receive a message with the JMS API
+ RedeliveryPolicy policy = connection.getRedeliveryPolicy();
+ policy.setUseExponentialBackOff(false);
+ policy.setMaximumRedeliveries(-1);
+ policy.setRedeliveryDelay(50);
+
+ connection.start();
+ Session pSession = connection.createSession(true,
Session.AUTO_ACKNOWLEDGE);
+ Session cSession = connection.createSession(true,
Session.AUTO_ACKNOWLEDGE);
+ ActiveMQQueue destination = new ActiveMQQueue("TEST");
+ this.makeSureCoreQueueExist("TEST");
+ MessageProducer producer = pSession.createProducer(destination);
+ MessageConsumer consumer = cSession.createConsumer(destination);
+
+ TextMessage m;
+
+ for (int i = 0; i < 5; ++i) {
+ producer.send(pSession.createTextMessage("MessageText"));
+ pSession.commit();
+ m = (TextMessage) consumer.receive(2000);
+ assertNotNull(m);
+ cSession.rollback();
+ m = (TextMessage) consumer.receive(2000);
+ assertNotNull(m);
+ cSession.commit();
+ }
+ ServerConsumer serverConsumer = null;
+ for (ServerSession session : server.getSessions()) {
+ for (ServerConsumer sessionConsumer : session.getServerConsumers()) {
+ if (sessionConsumer.getQueue().getName().toString() == "TEST") {
+ serverConsumer = sessionConsumer;
+ }
+ }
+ }
+ AMQConsumer amqConsumer = (AMQConsumer) serverConsumer.getProtocolData();
Review comment:
TBH I'm not a great fan as well to expose public members, but probably
there's no easier way to do 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]