...
read(MessageConsumer consumer
)
The method is called with an already instantiated MessageConsumer
object to receive a message from the MQ server. It extracts the value from the Message
object as a string representation via the Message
objects getText()
method.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
private String read(MessageConsumer consumer) { TextMessage message = null; String textMessage = null; try { while (true) { Message receivedMessage = consumer.receive(1); if (receivedMessage != null) { if (receivedMessage instanceof TextMessage) { message = (TextMessage) receivedMessage; textMessage = message.getText(); LOGGER.info("Reading message: " + textMessage); break; } else { break; } } } } catch (JMSException e) { LOGGER.error("JMSException occurred while trying to read from Destination: ", e); } return textMessage; } |
...