Skip to content

Commit

Permalink
Fix producer wrapper should not set delivery delay on wrapped resource
Browse files Browse the repository at this point in the history
The producer wrapper holds the delivery delay for the wrapped instance
and should not be setting the value on the underlying JMS producer which
could be shared amongst threads and can be retained across create calls
  • Loading branch information
tabish121 committed Oct 12, 2024
1 parent bceedd6 commit 9799c8c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ public void setDeliveryDelay(long deliveryDelay) throws JMSException {
session.checkClientJMSVersionSupport(2, 0);

this.deliveryDelay = deliveryDelay;
this.messageProducer.setDeliveryDelay(deliveryDelay);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.messaginghub.pooled.jms.mock.MockJMSDestination;
import org.messaginghub.pooled.jms.mock.MockJMSQueue;
import org.messaginghub.pooled.jms.mock.MockJMSTopic;

import jakarta.jms.CompletionListener;
import jakarta.jms.DeliveryMode;
import jakarta.jms.Destination;
Expand All @@ -33,12 +39,6 @@
import jakarta.jms.Queue;
import jakarta.jms.Session;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.messaginghub.pooled.jms.mock.MockJMSDestination;
import org.messaginghub.pooled.jms.mock.MockJMSQueue;
import org.messaginghub.pooled.jms.mock.MockJMSTopic;

/**
* Tests for the JMS Pool MessageProducer wrapper class.
*/
Expand Down Expand Up @@ -117,6 +117,26 @@ public void testSetDeliveryDelay() throws JMSException {
} catch (IllegalStateException ise) {}
}

@Test
public void testSetDeliveryDelayNoAppliedToUnderlyingProducer() throws JMSException {
JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection();

Session session = connection.createSession();
Queue queue = session.createTemporaryQueue();
MessageProducer producer1 = session.createProducer(queue);

assertEquals(0, producer1.getDeliveryDelay());
producer1.setDeliveryDelay(1);
assertEquals(1, producer1.getDeliveryDelay());

producer1.close();

MessageProducer producer2 = session.createProducer(queue);
assertEquals(0, producer2.getDeliveryDelay());
producer2.setDeliveryDelay(1);
assertEquals(1, producer2.getDeliveryDelay());
}

@Test
public void testSetPriority() throws JMSException {
JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection();
Expand Down

0 comments on commit 9799c8c

Please sign in to comment.