@Test public void testGetGreeting() { try { publisherPublishSubscribe.sendName("Peregrin", "Took"); String greeting1 = subscriberPublishSubscribe.getGreeting(1000); assertEquals("Hello Peregrin Took!", greeting1); String greeting2 = subscriberPublishSubscribe.getGreeting(1000); assertEquals("no greeting", greeting2); } catch (JMSException e) { fail("a JMS Exception occurred"); } }
public String getGreeting(int timeout) throws JMSException { String greeting = NO_GREETING; Message message = messageConsumer.receive(timeout); if (message != null) { TextMessage textMessage = (TextMessage) message; String text = textMessage.getText(); LOGGER.debug(clientId + ": received message with text='{}'", text); greeting = "Hello " + text + "!"; } else { LOGGER.debug(clientId + ": no message received"); } LOGGER.info("greeting={}", greeting); return greeting; }
DurableSubscriber { public String getGreeting(int timeout) throws JMSException { String greeting = NO_GREETING; Message message = messageConsumer.receive(timeout); if (message != null) { TextMessage textMessage = (TextMessage) message; String text = textMessage.getText(); LOGGER.debug(clientId + ": received message with text='{}'", text); greeting = "Hello " + text + "!"; } else { LOGGER.debug(clientId + ": no message received"); } LOGGER.info("greeting={}", greeting); return greeting; } }
DurableSubscriber { public String getGreeting(int timeout) throws JMSException { String greeting = NO_GREETING; Message message = messageConsumer.receive(timeout); if (message != null) { TextMessage textMessage = (TextMessage) message; String text = textMessage.getText(); LOGGER.debug(clientId + ": received message with text='{}'", text); greeting = "Hello " + text + "!"; } else { LOGGER.debug(clientId + ": no message received"); } LOGGER.info("greeting={}", greeting); return greeting; }  }
DurableSubscriber { public String getGreeting(int timeout) throws JMSException { String greeting = NO_GREETING; Message message = messageConsumer.receive(timeout); if (message != null) { TextMessage textMessage = (TextMessage) message; String text = textMessage.getText(); LOGGER.debug(clientId + ": received message with text='{}'", text); greeting = "Hello " + text + "!"; } else { LOGGER.debug(clientId + ": no message received"); } LOGGER.info("greeting={}", greeting); return greeting; }  void create(String clientId, String topicName,
            String subscriptionName); void removeDurableSubscriber(); void closeConnection(); String getGreeting(int timeout); }
DurableSubscriber { public String getGreeting(int timeout) throws JMSException { String greeting = NO_GREETING; Message message = messageConsumer.receive(timeout); if (message != null) { TextMessage textMessage = (TextMessage) message; String text = textMessage.getText(); LOGGER.debug(clientId + ": received message with text='{}'", text); greeting = "Hello " + text + "!"; } else { LOGGER.debug(clientId + ": no message received"); } LOGGER.info("greeting={}", greeting); return greeting; }  void create(String clientId, String topicName,
            String subscriptionName); void removeDurableSubscriber(); void closeConnection(); String getGreeting(int timeout);  }