コード例 #1
0
 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;
   }
 }
コード例 #2
0
  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);
    }
  }
コード例 #3
0
 protected static void receiveMessage(JMSConsumer consumer, String expectedText)
     throws NamingException {
   String text = consumer.receiveBody(String.class, 5000);
   assertNotNull(text);
   assertEquals(expectedText, text);
 }