javax.jms.Queue Java Examples
The following examples show how to use
javax.jms.Queue.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GeneralInteropTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
private void sendMultipleTextMessagesUsingCoreJms(String queueName, String text, int num) throws Exception { Connection jmsConn = null; try { jmsConn = coreCf.createConnection(); Session session = jmsConn.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue(queueName); MessageProducer producer = session.createProducer(queue); for (int i = 0; i < num; i++) { TextMessage msg = session.createTextMessage(text + i); producer.send(msg); } } finally { if (jmsConn != null) { jmsConn.close(); } } }
Example #2
Source File: TextMessageTest.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Test public void sendAndReceiveEmpty() throws Exception { Queue queue = createQueue(getTestName()); Connection connection = getConnection(); try { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = session.createProducer(queue); TextMessage message = session.createTextMessage(null); producer.send(message); MessageConsumer consumer = session.createConsumer(queue); connection.start(); Message receivedMessage = consumer.receive(getReceiveTimeout()); assertTrue("TextMessage should be received", receivedMessage instanceof TextMessage); assertNull("Unexpected body", ((TextMessage) receivedMessage).getText()); } finally { connection.close(); } }
Example #3
Source File: ApplicationLayerFailoverExample.java From activemq-artemis with Apache License 2.0 | 6 votes |
private static void createJMSObjects(final int server) throws Exception { // Step 1. Instantiate a JMS Connection Factory object from JNDI on server 1 ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://127.0.0.1:" + (61616 + server)); // Step 2. We create a JMS Connection connection connection = connectionFactory.createConnection(); // Step 3. We start the connection to ensure delivery occurs connection.start(); // Step 4. We create a JMS Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // Step 5. Look-up the JMS Queue object from JNDI Queue queue = session.createQueue("exampleQueue"); // Step 6. We create a JMS MessageConsumer object consumer = session.createConsumer(queue); // Step 7. We create a JMS MessageProducer object producer = session.createProducer(queue); }
Example #4
Source File: MessagingMessageListenerAdapterTests.java From spring-analysis-note with MIT License | 6 votes |
public TextMessage testReplyWithJackson(String methodName, String replyContent) throws JMSException { Queue replyDestination = mock(Queue.class); Session session = mock(Session.class); MessageProducer messageProducer = mock(MessageProducer.class); TextMessage responseMessage = mock(TextMessage.class); given(session.createTextMessage(replyContent)).willReturn(responseMessage); given(session.createProducer(replyDestination)).willReturn(messageProducer); MessagingMessageListenerAdapter listener = getPayloadInstance("Response", methodName, Message.class); MappingJackson2MessageConverter messageConverter = new MappingJackson2MessageConverter(); messageConverter.setTargetType(MessageType.TEXT); listener.setMessageConverter(messageConverter); listener.setDefaultResponseDestination(replyDestination); listener.onMessage(mock(javax.jms.Message.class), session); verify(session, times(0)).createQueue(anyString()); verify(session).createTextMessage(replyContent); verify(messageProducer).send(responseMessage); verify(messageProducer).close(); return responseMessage; }
Example #5
Source File: JmsQueueBrowserTest.java From pooled-jms with Apache License 2.0 | 6 votes |
@Test public void testGetEnumeration() throws JMSException { JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection(); QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createTemporaryQueue(); QueueBrowser browser = session.createBrowser(queue); assertNotNull(browser.getEnumeration()); browser.close(); try { browser.getEnumeration(); fail("Should not be able to use a closed browser"); } catch (IllegalStateException ise) { } }
Example #6
Source File: BrowserTest.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Test public void emptyQueue() throws Exception { Queue queue = createQueue(getTestName()); Connection connection = getConnection(); try { connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); QueueBrowser browser = session.createBrowser(queue); Enumeration enumeration = browser.getEnumeration(); assertFalse(enumeration.hasMoreElements()); } finally { connection.close(); } }
Example #7
Source File: SimpleOpenWireTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test public void testTransactionalSimple() throws Exception { try (Connection connection = factory.createConnection()) { Session session = connection.createSession(true, Session.SESSION_TRANSACTED); Queue queue = session.createQueue(queueName); MessageProducer producer = session.createProducer(queue); MessageConsumer consumer = session.createConsumer(queue); producer.send(session.createTextMessage("test")); session.commit(); Assert.assertNull(consumer.receive(100)); connection.start(); TextMessage message = (TextMessage) consumer.receive(5000); Assert.assertEquals("test", message.getText()); Assert.assertNotNull(message); message.acknowledge(); } }
Example #8
Source File: QueueReceiverTest.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Test public void createReceiver() throws Exception { Queue queue = createQueue(getTestName()); QueueConnection queueConnection = getQueueConnection(); try { queueConnection.start(); Utils.sendMessages(queueConnection, queue, 3); QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); QueueReceiver receiver = session.createReceiver(queue, String.format("%s=2", INDEX)); assertEquals("Queue names should match from QueueReceiver", queue.getQueueName(), receiver.getQueue().getQueueName()); Message received = receiver.receive(getReceiveTimeout()); assertNotNull("Message is not received", received); assertEquals("Unexpected message is received", 2, received.getIntProperty(INDEX)); } finally { queueConnection.close(); } }
Example #9
Source File: InitConfServer.java From blog with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void onMessage(Message message) { try { TextMessage receiveMessage = (TextMessage) message; String keys = receiveMessage.getText(); LOGGER.info("keys = " + keys); MapMessage returnMess = session.createMapMessage(); returnMess.setStringProperty("/a2/m1", "zhaohui"); returnMess.setStringProperty("/a3/m1/v2", "nanjing"); returnMess.setStringProperty("/a3/m1/v2/t2", "zhaohui"); QueueSender sender = session.createSender((Queue) message.getJMSReplyTo()); sender.send(returnMess); } catch (Exception e) { LOGGER.error("onMessage error", e); } }
Example #10
Source File: MessagingMessageListenerAdapterTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void replyPayloadNoDestination() throws JMSException { Queue replyDestination = mock(Queue.class); Message<String> request = MessageBuilder.withPayload("Response").build(); Session session = mock(Session.class); MessageProducer messageProducer = mock(MessageProducer.class); TextMessage responseMessage = mock(TextMessage.class); given(session.createTextMessage("Response")).willReturn(responseMessage); given(session.createProducer(replyDestination)).willReturn(messageProducer); MessagingMessageListenerAdapter listener = getPayloadInstance(request, "replyPayloadNoDestination", Message.class); listener.setDefaultResponseDestination(replyDestination); listener.onMessage(mock(javax.jms.Message.class), session); verify(session, times(0)).createQueue(anyString()); verify(session).createTextMessage("Response"); verify(messageProducer).send(responseMessage); verify(messageProducer).close(); }
Example #11
Source File: JmsLargeMessageSendRecvTimedTest.java From qpid-jms with Apache License 2.0 | 5 votes |
public void doTestSendLargeMessage(int expectedSize) throws Exception{ LOG.info("doTestSendLargeMessage called with expectedSize " + expectedSize); byte[] payload = createLargePayload(expectedSize); assertEquals(expectedSize, payload.length); Connection connection = createAmqpConnection(); long startTime = System.currentTimeMillis(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue(name.getMethodName()); MessageProducer producer = session.createProducer(queue); BytesMessage message = session.createBytesMessage(); message.writeBytes(payload); producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); // Set this to non-default to get a Header in the encoded message. producer.setPriority(4); producer.send(message); long endTime = System.currentTimeMillis(); LOG.info("Returned from send after {} ms", endTime - startTime); startTime = System.currentTimeMillis(); MessageConsumer consumer = session.createConsumer(queue); connection.start(); LOG.info("Calling receive"); Message received = consumer.receive(); assertNotNull(received); assertTrue(received instanceof BytesMessage); BytesMessage bytesMessage = (BytesMessage) received; assertNotNull(bytesMessage); endTime = System.currentTimeMillis(); LOG.info("Returned from receive after {} ms", endTime - startTime); byte[] bytesReceived = new byte[expectedSize]; assertEquals(expectedSize, bytesMessage.readBytes(bytesReceived, expectedSize)); assertTrue(Arrays.equals(payload, bytesReceived)); connection.close(); }
Example #12
Source File: JmsSessionTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test(timeout=30000) public void testCreateTemporaryQueue() throws Exception { connection = createAmqpConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createTemporaryQueue(); assertNotNull(queue); assertTrue(queue instanceof TemporaryQueue); final BrokerViewMBean broker = getProxyToBroker(); assertEquals(1, broker.getTemporaryQueues().length); }
Example #13
Source File: BrokerNetworkWithStuckMessagesTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@SuppressWarnings("unused") private Object[] browseQueueWithJms(BrokerService broker) throws Exception { Object[] messages = null; Connection connection = null; Session session = null; try { URI brokerUri = connector.getUri(); ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerUri.toString()); connection = connectionFactory.createConnection(); connection.start(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue destination = session.createQueue(queueName); QueueBrowser browser = session.createBrowser(destination); List<Message> list = new ArrayList<>(); for (Enumeration<Message> enumn = browser.getEnumeration(); enumn.hasMoreElements(); ) { list.add(enumn.nextElement()); } messages = list.toArray(); } finally { if (session != null) { session.close(); } if (connection != null) { connection.close(); } } LOG.info("+Browsed with JMS: " + messages.length); return messages; }
Example #14
Source File: MaxDeliveryTest.java From qpid-broker-j with Apache License 2.0 | 5 votes |
@Test public void browsingDoesNotIncrementDeliveryCount() throws Exception { assumeThat(getBrokerAdmin().isManagementSupported(), is(true)); final String queueName = getTestName(); getBrokerAdmin().createQueue(queueName); Connection connection = getConnection(); try { connection.start(); final Session session = connection.createSession(true, Session.SESSION_TRANSACTED); final Queue queue = session.createQueue(queueName); Utils.sendMessages(connection, queue, 1); final Map<String, Object> messageInfoBefore = getMessageInfo(queueName, 0); assertThat("Unexpected delivery count before browse", messageInfoBefore.get("deliveryCount"), is(equalTo(0))); browseQueueAndValidationDeliveryHeaders(session, queue); final Map<String, Object> messageInfoAfter = getMessageInfo(queueName, 0); assertThat("Unexpected delivery count after first browse", messageInfoAfter.get("deliveryCount"), is(equalTo(0))); browseQueueAndValidationDeliveryHeaders(session, queue); } finally { connection.close(); } }
Example #15
Source File: CmsListener.java From oneops with Apache License 2.0 | 5 votes |
/** * Inits the. * * @throws JMSException the jMS exception */ public void init() throws JMSException { connection = connFactory.createConnection(); connection.setClientID(consumerName); session = connection.createSession(true, Session.SESSION_TRANSACTED); Queue queue = session.createQueue(queueName); MessageConsumer consumer = session.createConsumer(queue); consumer.setMessageListener(this); connection.start(); logger.info(">>>>>>>>>>>>>>CmsListener Waiting for messages..."); }
Example #16
Source File: GroupingTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void send(JMSContext ctx, Queue testQueue, String groupID1, JMSProducer producer1, int j) throws JMSException { TextMessage message = ctx.createTextMessage("Message" + j); producer1.send(testQueue, message); String prop = message.getStringProperty("JMSXGroupID"); assertNotNull(prop); assertEquals(groupID1, prop); }
Example #17
Source File: QueueLocalTransactionCommitTest.java From ballerina-message-broker with Apache License 2.0 | 5 votes |
@Parameters({"broker-port", "admin-username", "admin-password", "broker-hostname"}) @Test(expectedExceptions = javax.jms.IllegalStateException.class, expectedExceptionsMessageRegExp = ".*Session is not transacted") public void testCommitOnNonTransactionSession(String port, String adminUsername, String adminPassword, String brokerHostname) throws NamingException, JMSException { String queueName = "testCommitOnNonTransactionSession"; InitialContext initialContextForQueue = ClientHelper .getInitialContextBuilder(adminUsername, adminPassword, brokerHostname, port) .withQueue(queueName) .build(); ConnectionFactory connectionFactory = (ConnectionFactory) initialContextForQueue.lookup(ClientHelper.CONNECTION_FACTORY); Connection connection = connectionFactory.createConnection(); connection.start(); // send 100 messages Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = producerSession.createQueue(queueName); MessageProducer producer = producerSession.createProducer(queue); int numberOfMessages = 100; for (int i = 0; i < numberOfMessages; i++) { producer.send(producerSession.createTextMessage("Test message " + i)); } //catch exception and re-throw it since we need the connection to be closed try { // commit all sent messages on non transactional session producerSession.commit(); } catch (Exception e) { throw e; } finally { producerSession.close(); connection.close(); } }
Example #18
Source File: JmsTopicSession.java From qpid-jms with Apache License 2.0 | 5 votes |
/** * @see javax.jms.Session#createProducer(javax.jms.Destination) */ @Override public MessageProducer createProducer(Destination destination) throws JMSException { if (destination instanceof Queue) { throw new IllegalStateException("Operation not supported by a TopicSession"); } return super.createProducer(destination); }
Example #19
Source File: JmsTemplate.java From java-technology-stack with MIT License | 5 votes |
@Nullable private Queue getDefaultQueue() { Destination defaultDestination = getDefaultDestination(); if (defaultDestination != null && !(defaultDestination instanceof Queue)) { throw new IllegalStateException( "'defaultDestination' does not correspond to a Queue. Check configuration of JmsTemplate."); } return (Queue) defaultDestination; }
Example #20
Source File: JmsTemplate.java From java-technology-stack with MIT License | 5 votes |
@Override @Nullable public <T> T browse(BrowserCallback<T> action) throws JmsException { Queue defaultQueue = getDefaultQueue(); if (defaultQueue != null) { return browse(defaultQueue, action); } else { return browse(getRequiredDefaultDestinationName(), action); } }
Example #21
Source File: JmsMessageConsumerTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void testMessagesAreAckedAMQProducer() throws Exception { int messagesSent = 3; assertTrue(brokerService.isPersistent()); connection = createActiveMQConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue(name.getMethodName()); MessageProducer p = session.createProducer(queue); TextMessage message = null; for (int i=0; i < messagesSent; i++) { message = session.createTextMessage(); String messageText = "Hello " + i + " sent at " + new java.util.Date().toString(); message.setText(messageText); LOG.debug(">>>> Sent [{}]", messageText); p.send(message); } connection.close(); // After the first restart we should get all messages sent above restartPrimaryBroker(); QueueViewMBean proxy = getProxyToQueue(name.getMethodName()); assertEquals(messagesSent, proxy.getQueueSize()); int messagesReceived = readAllMessages(); assertEquals(messagesSent, messagesReceived); // This time there should be no messages on this queue restartPrimaryBroker(); proxy = getProxyToQueue(name.getMethodName()); assertEquals(0, proxy.getQueueSize()); }
Example #22
Source File: FailureXATest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void doTestCrashServerAfterXACommit(boolean onePhase) throws Exception { ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(); XAConnection connection = connectionFactory.createXAConnection(); try { Session session = connection.createSession(true, Session.SESSION_TRANSACTED); Queue queue = session.createQueue("Queue1"); final XASession xaSession = connection.createXASession(); MessageConsumer consumer = xaSession.createConsumer(queue); MessageProducer producer = session.createProducer(queue); producer.send(session.createTextMessage("hello " + 1)); session.commit(); XAResource xaResource = xaSession.getXAResource(); final Xid xid = newXID(); xaResource.start(xid, XAResource.TMNOFLAGS); connection.start(); Assert.assertNotNull(consumer.receive(5000)); xaResource.end(xid, XAResource.TMSUCCESS); try { xaResource.commit(xid, onePhase); Assert.fail("didn't get expected exception!"); } catch (XAException xae) { if (onePhase) { //expected error code is XAER_RMFAIL Assert.assertEquals(XAException.XAER_RMFAIL, xae.errorCode); } else { //expected error code is XA_RETRY Assert.assertEquals(XAException.XA_RETRY, xae.errorCode); } } } finally { connection.close(); } }
Example #23
Source File: IndexRequestListener.java From development with Apache License 2.0 | 5 votes |
private boolean putBackMessageOnIndexerQueue(Message message) { if (message instanceof ObjectMessage) { Session session = null; Connection conn = null; try { Context jndiContext = getContext(); ConnectionFactory qFactory = (ConnectionFactory) jndiContext .lookup("jms/bss/indexerQueueFactory"); conn = qFactory.createConnection(); Queue queue = (Queue) jndiContext .lookup("jms/bss/indexerQueue"); session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = session.createProducer(queue); ObjectMessage msg = session.createObjectMessage(); msg.setObject(((ObjectMessage) message).getObject()); producer.send(msg); return true; } catch (Throwable e) { // This should not happen because the indexer queue is in the // local server. If it happens, than there's something terribly // wrong. throw new SaaSSystemException(e); } finally { closeSession(session); closeConnection(conn); } } else { return false; } }
Example #24
Source File: DupsOkTest.java From qpid-broker-j with Apache License 2.0 | 5 votes |
@Test public void synchronousReceive() throws Exception { Queue queue = createQueue(getTestName()); Connection connection = getConnection(); final int numberOfMessages = 3; try { connection.start(); Utils.sendMessages(connection, queue, numberOfMessages); Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE); MessageConsumer consumer = session.createConsumer(queue); for (int i = 0; i < numberOfMessages; i++) { Message received = consumer.receive(getReceiveTimeout()); assertNotNull(String.format("Expected message (%d) not received", i), received); assertEquals("Unexpected message received", i, received.getIntProperty(INDEX)); } assertNull("Received too many messages", consumer.receive(getReceiveTimeout()/4)); } finally { connection.close(); } }
Example #25
Source File: SelectorTest.java From qpid-broker-j with Apache License 2.0 | 5 votes |
@Test public void runtimeSelectorError() throws Exception { Connection connection = getConnection(); Queue queue = createQueue(getTestName()); try { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = session.createConsumer(queue , "testproperty % 5 = 1"); MessageProducer producer = session.createProducer(queue); Message message = session.createMessage(); message.setIntProperty("testproperty", 1); // 1 % 5 producer.send(message); connection.start(); Message receivedMessage = consumer.receive(getReceiveTimeout()); assertNotNull("Message matching selector should be received", receivedMessage); message.setStringProperty("testproperty", "hello"); // "hello" % 5 would cause a runtime error producer.send(message); receivedMessage = consumer.receive(getReceiveTimeout()); assertNull("Message causing runtime selector error should not be received", receivedMessage); MessageConsumer consumerWithoutSelector = session.createConsumer(queue); receivedMessage = consumerWithoutSelector.receive(getReceiveTimeout()); assertNotNull("Message that previously caused a runtime error should be consumable by another consumer", receivedMessage); } finally { connection.close(); } }
Example #26
Source File: VirtualTopicMappingExample.java From activemq-artemis with Apache License 2.0 | 5 votes |
public static void main(final String[] args) throws Exception { Connection connection = null; try { ConnectionFactory cf = new ActiveMQConnectionFactory(); connection = cf.createConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); //create consumer on queue that is used by the Virtual Topic Queue queue = session.createQueue("Consumer.A.VirtualTopic.Orders"); MessageConsumer messageConsumer = session.createConsumer(queue); connection.start(); //send message to virtual topic Topic topic = session.createTopic("VirtualTopic.Orders"); MessageProducer producer = session.createProducer(topic); TextMessage message = session.createTextMessage("This is a text message"); producer.send(message); System.out.println("Sent message with ID: " + message.getJMSMessageID() + " to Topic: " + topic.getTopicName()); //consume the message from the backing queue TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000); if (messageReceived != null) { System.out.println("Received message with ID: " + messageReceived.getJMSMessageID() + " from Queue: " + queue.getQueueName()); } else { //unexpected outcome throw new RuntimeException("EXAMPLE FAILED - No message received from Queue: " + queue.getQueueName()); } } finally { if (connection != null) { connection.close(); } } }
Example #27
Source File: JMSMessageHeadersType.java From cxf with Apache License 2.0 | 5 votes |
private String getDestName(Message message) throws JMSException { Destination replyTo = message.getJMSReplyTo(); if (replyTo instanceof Queue) { return ((Queue)replyTo).getQueueName(); } else if (replyTo instanceof Topic) { return ((Topic)replyTo).getTopicName(); } return null; }
Example #28
Source File: CriticalAnalyzerFaultInjectionTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void sendConsumeDurableMessage() throws Exception { try { Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue jmsQueue = s.createQueue(address.toString()); MessageProducer p = s.createProducer(jmsQueue); p.setDeliveryMode(DeliveryMode.PERSISTENT); conn.start(); p.send(s.createTextMessage("payload")); } catch (JMSException expected) { } finally { if (conn != null) { conn.close(); } } }
Example #29
Source File: JMSClusteredTestBase.java From activemq-artemis with Apache License 2.0 | 5 votes |
/** * @throws Exception */ protected Queue createQueue(final String name) throws Exception { jmsServer2.createQueue(false, name, null, true, "/queue/" + name); jmsServer1.createQueue(false, name, null, true, "/queue/" + name); assertTrue(waitForBindings(server1, name, false, 1, 0, 10000)); assertTrue(waitForBindings(server2, name, false, 1, 0, 10000)); return (Queue) context1.lookup("/queue/" + name); }
Example #30
Source File: FailoverTransactionTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testAutoRollbackWithMissingRedeliveries() throws Exception { LOG.info(this + " running test testAutoRollbackWithMissingRedeliveries"); broker = createBroker(); broker.start(); ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + url + ")"); configureConnectionFactory(cf); Connection connection = cf.createConnection(); try { connection.start(); final Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); final Queue destination = producerSession.createQueue(QUEUE_NAME + "?consumer.prefetchSize=1"); final Session consumerSession = connection.createSession(true, Session.SESSION_TRANSACTED); MessageConsumer consumer = consumerSession.createConsumer(destination); produceMessage(producerSession, destination); Message msg = consumer.receive(20000); Assert.assertNotNull(msg); broker.stop(); broker = createBroker(); // use empty jdbc store so that default wait(0) for redeliveries will timeout after failover broker.start(); try { consumerSession.commit(); Assert.fail("expected transaction rolledback ex"); } catch (TransactionRolledBackException expected) { } broker.stop(); broker = createBroker(); broker.start(); Assert.assertNotNull("should get rolledback message from original restarted broker", consumer.receive(20000)); } finally { connection.close(); } }