I am writing a stand alone main method which invokes a producer (to push data into a queue), and then invokes a consumer which keeps listening to the topic.
I have overridden the onMessage and I am able to get the message from the queue, but I am not able to return the message to the calling method.
Actually, I want to carry the message to the browser, thus wanted to test if I can carry it atleast till main.
Please help;
class TextMessageListener implements MessageListener {
String msgData;
public String getMsgData() {
return msgData;
}
public void setMsgData(String msgData) {
this.msgData = msgData;
}
public void onMessage(Message message) {
try {
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
System.out.println("Received message in ::" + textMessage.getText() + " '");
setMsgData(textMessage.getText());
}
} catch (JMSException e) {
System.out.println("Caught:" + e);
e.printStackTrace();
}
}
}