Add test case for session with local transactions.

This commit is contained in:
Timothy Bish 2014-02-10 12:20:44 -05:00
parent 519d8f7db0
commit 1e7dc12c30
1 changed files with 34 additions and 0 deletions

View File

@ -694,6 +694,40 @@ public class JMSClientTest extends AmqpTestSupport {
assertTrue("No exception listener event fired.", called.await(15, TimeUnit.SECONDS));
}
@Test
public void testSessionTransactedCommit() throws JMSException, InterruptedException {
Connection connection = createConnection();
Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(name.toString());
connection.start();
// transacted producer
MessageProducer pr = session.createProducer(queue);
for (int i = 0; i < 10; i++) {
Message m = session.createTextMessage("TestMessage" + i);
pr.send(m);
}
// No commit in place, so no message should be dispatched.
MessageConsumer consumer = session.createConsumer(queue);
TextMessage m = (TextMessage) consumer.receive(5000);
assertNull(m);
session.commit();
// Messages should be available now.
for (int i = 0; i < 10; i++) {
Message msg = consumer.receive(5000);
assertNotNull(msg);
}
session.close();
connection.close();
}
private Connection createConnection() throws JMSException {
return createConnection(name.toString(), false);
}