Skip to content

Instantly share code, notes, and snippets.

Created October 23, 2015 13:48
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save scholzj/45dfc385a06c7ac971a8 to your computer and use it in GitHub Desktop.
Closing of receiver on top of tx session
package org.apache.qpid.jms.transactions;
import org.junit.Test;
import javax.jms.*;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
* Created by schojak on 23.10.15.
public class JmsTransactedReceiverCloseTest extends AmqpTestSupport {
@Test(timeout = 60000)
public void testReceiverClose() throws Exception {
connection = createAmqpConnection();
Session mgmtSession = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
Queue queue = mgmtSession.createQueue(name.getMethodName());
// Sender
Session session1 = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
MessageProducer sender = session1.createProducer(queue);
// Tx Receiver with Rollback
Session session2 = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
MessageConsumer receiver2 = session2.createConsumer(queue);
Message received2 = receiver2.receive(1000);
assertNotNull("receiver3 didn't received the message", received2);
// Normal Receiver
Session session3 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer receiver3 = session3.createConsumer(queue);
Message received3 = receiver3.receive(1000);
assertNotNull("receiver3 didn't received the message", received3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment