Scenario
I am consuming messages from a WebLogic Queue by implementing messageListener. The onMessage() call is successful and the message received can be printed from within the onMessage function.
Requirement
To process this msgText as soon as it received and return the processed result to a calling method.
Code
@Override
public void onMessage(Message msg) {
try {
String msgText;
if (msg instanceof TextMessage) {
msgText = ((TextMessage) msg).getText();
} else {
msgText = msg.toString();
}
System.out.println(msgText);
} catch (JMSException ex) {
ex.printStackTrace();
}
}