QueueResource { @GET public String getMessage() throws JMSException { XAConnection connection = xaConnectionFactory.createXAConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = session.createConsumer(queue); connection.start(); TextMessage message = (TextMessage) consumer.receive(5000); connection.close(); session.close(); if (message != null) return message.getText(); return null; }  @POST @TransactionAttribute(TransactionAttributeType.MANDATORY) Response sendNotification(@QueryParam("message") String message); @GET String getMessage();  }
@Test public void testCommit() throws Exception { System.out.println("QueueResourceTest.testCommit()"); System.out.println("Starting REST-AT transaction..."); txSupport.startTx(); sendMessage(TEST_MESSAGE); System.out.println("Commiting REST-AT transaction..."); txSupport.commitTx(); Assert.assertEquals(TEST_MESSAGE, getMessage()); }
@Test public void testRollback() throws Exception { System.out.println("QueueResourceTest.testRollback()"); System.out.println("Starting REST-AT transaction..."); txSupport.startTx(); sendMessage(TEST_MESSAGE); System.out.println("Rolling back REST-AT transaction..."); txSupport.rollbackTx(); Assert.assertEquals(null, getMessage()); }