Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BEAP-16034] Core JMS client leaks temporary destination names #281

Open
wants to merge 1 commit into
base: 2.6.3.jbossorg-x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ public void addTemporaryQueue(final SimpleString queueAddress) {

public void removeTemporaryQueue(final SimpleString queueAddress) {
tempQueues.remove(queueAddress);
knownDestinations.remove(queueAddress);
}

public void addKnownDestination(final SimpleString address) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import javax.jms.TextMessage;
import javax.naming.NamingException;

import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.jms.client.ActiveMQConnection;
import org.apache.activemq.artemis.jms.tests.util.ProxyAssertSupport;
import org.junit.Test;

Expand Down Expand Up @@ -126,6 +128,51 @@ public void testTemporaryQueueBasic() throws Exception {
}
}

@Test
public void testTemporaryQueueLeak() throws Exception {
ActiveMQConnection conn = null;

try {
conn = (ActiveMQConnection) createConnection();

Session producerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);

Session consumerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);

TemporaryQueue tempQueue = producerSession.createTemporaryQueue();

MessageProducer producer = producerSession.createProducer(tempQueue);

MessageConsumer consumer = consumerSession.createConsumer(tempQueue);

conn.start();

final String messageText = "This is a message";

Message m = producerSession.createTextMessage(messageText);

producer.send(m);

TextMessage m2 = (TextMessage) consumer.receive(2000);

ProxyAssertSupport.assertNotNull(m2);

ProxyAssertSupport.assertEquals(messageText, m2.getText());

consumer.close();

tempQueue.delete();

ProxyAssertSupport.assertFalse(conn.containsKnownDestination(SimpleString.toSimpleString(tempQueue.getQueueName())));

ProxyAssertSupport.assertFalse(conn.containsTemporaryQueue(SimpleString.toSimpleString(tempQueue.getQueueName())));
} finally {
if (conn != null) {
conn.close();
}
}
}

/**
* http://jira.jboss.com/jira/browse/JBMESSAGING-93
*/
Expand Down