count = (Integer)ServerManagement.getAttribute(queueMBean, "MessageCount");
assertEquals(2, count.intValue());
xaConn = cf.createXAConnection();
XASession xaSession = xaConn.createXASession();
xaConn.start();
DummyListener listener = new DummyListener();
xaSession.setMessageListener(listener);
ServerSessionPool pool = new MockServerSessionPool(xaSession);
xaConn.createConnectionConsumer(queue1, null, pool, 1);
Thread.sleep(1000);
assertEquals(2, listener.messages.size());
assertEquals("message1", ((TextMessage)listener.messages.get(0)).getText());
assertEquals("message2", ((TextMessage)listener.messages.get(1)).getText());
count = (Integer)ServerManagement.getAttribute(queueMBean, "MessageCount");
assertEquals(2, count.intValue());
listener.messages.clear();
// Now we enlist the session in an xa transaction
XAResource res = xaSession.getXAResource();
tm.begin();
Transaction tx = tm.getTransaction();
tx.enlistResource(res);