// If it's a text message, print it to stdout
if (msg instanceof TextMessage) {
TextMessage tMsg = (TextMessage)msg;
try {
System.out.println("Received message: " + tMsg.getText());
}
catch (JMSException je) {
System.out.println("Error retrieving message text: " +
je.getMessage());
}
}
// For other types of messages, print an error
else {
System.out.println("Unsupported message type encountered.");
}