conn.close();
}
public void testTransactionRollback() throws Exception
{
MessageStore store = ServerManagement.getMessageStore();
Connection conn = cf.createConnection();
Session sess = conn.createSession(true, Session.SESSION_TRANSACTED);
MessageProducer prod = sess.createProducer(queue);
MessageConsumer cons = sess.createConsumer(queue);
conn.start();
TextMessage m = sess.createTextMessage("wibble");
prod.send(m);
sess.commit();
TextMessage m2 = (TextMessage)cons.receive(1000);
assertNotNull(m2);
assertEquals(m.getText(), m2.getText());
MessageReference ref = store.reference(((MessageProxy)m2).getMessage().getMessageID());
assertEquals(((MessageProxy)m).getMessage().getMessageID(), ref.getMessage().getMessageID());
ref.releaseMemoryReference();
sess.rollback();
TextMessage m3 = (TextMessage)cons.receive();
assertNotNull(m3);
assertEquals(m.getText(), m3.getText());
ref = store.reference(((MessageProxy)m3).getMessage().getMessageID());
assertEquals(((MessageProxy)m).getMessage().getMessageID(), ref.getMessage().getMessageID());
ref.releaseMemoryReference();
sess.commit();
ref = store.reference(((MessageProxy)m2).getMessage().getMessageID());
assertNull(ref);
conn.close();
}