public String receiveMessage() { try (JMSConsumer consumer = context.createConsumer(pointsQueue)) { String message = consumer.receiveBody(String.class); Logger.getLogger(ReceivePointsBean.class.getName()) .log(Level.INFO, "Received message: " + message); return message; } }
protected static void receiveMessage(Context ctx, String destinationLookup, String expectedText) throws NamingException { ConnectionFactory cf = (ConnectionFactory) ctx.lookup("jms/RemoteConnectionFactory"); assertNotNull(cf); Destination destination = (Destination) ctx.lookup(destinationLookup); assertNotNull(destination); try (JMSContext context = cf.createContext("guest", "guest")) { JMSConsumer consumer = context.createConsumer(destination); String text = consumer.receiveBody(String.class, 5000); assertNotNull(text); assertEquals(expectedText, text); } }
protected static void receiveMessage(JMSConsumer consumer, String expectedText) throws NamingException { String text = consumer.receiveBody(String.class, 5000); assertNotNull(text); assertEquals(expectedText, text); }