TextMessage m = (TextMessage) receiver.receiveNoWait();
/** * Test that a call to the <code>rollback()</code> method on a * <strong>transacted</strong> <code>Session</code> rollbacks all * the messages sent in the transaction. */ public void testRollbackTransactedSession() { try { // re-create senderSession as a transacted session senderSession = senderConnection.createQueueSession(true, 0); sender = senderSession.createSender(senderQueue); assertEquals(true, senderSession.getTransacted()); TextMessage message = senderSession.createTextMessage(); message.setText("testRollbackTransactedSession"); // send a message within a transacted session sender.send(message); // rollback the transaction -> the sent message shouldn't be received senderSession.rollback(); TextMessage m = (TextMessage) receiver.receiveNoWait(); // test that no message has been received assertEquals(null, m); } catch (Exception e) { fail(e); } }
/** * Test that a call to the <code>rollback()</code> method on a * <strong>transacted</strong> <code>Session</code> rollbacks all * the messages sent in the transaction. */ @Test public void testCommitTransactedSession() { try { // re-create senderSession as a transacted session senderSession = senderConnection.createQueueSession(true, 0); sender = senderSession.createSender(senderQueue); Assert.assertEquals(true, senderSession.getTransacted()); TextMessage message = senderSession.createTextMessage(); message.setText("testCommitTransactedSession"); // send a message within a transacted session sender.send(message); TextMessage m = (TextMessage) receiver.receiveNoWait(); // test that no message has been received (the transaction has not been committed yet) Assert.assertEquals(null, m); // commit the transaction -> the sent message should be received senderSession.commit(); m = (TextMessage) receiver.receive(TestConfig.TIMEOUT); Assert.assertTrue(m != null); Assert.assertEquals("testCommitTransactedSession", m.getText()); } catch (Exception e) { fail(e); } }
/** * Test that a call to the <code>rollback()</code> method on a * <strong>transacted</strong> <code>Session</code> rollbacks all * the messages sent in the transaction. */ @Test public void testRollbackTransactedSession() { try { // re-create senderSession as a transacted session senderSession = senderConnection.createQueueSession(true, 0); sender = senderSession.createSender(senderQueue); Assert.assertEquals(true, senderSession.getTransacted()); TextMessage message = senderSession.createTextMessage(); message.setText("testRollbackTransactedSession"); // send a message within a transacted session sender.send(message); // rollback the transaction -> the sent message shouldn't be received senderSession.rollback(); TextMessage m = (TextMessage) receiver.receiveNoWait(); // test that no message has been received Assert.assertEquals(null, m); } catch (Exception e) { fail(e); } }