A MessageConsumer retrieves a TextMessage.

Enterprise Java
Guarantee Inter-Enterprise Message Delivery Using JMS
Gopalan Suresh Raj
Listing 5. A MessageConsumer retrieves a TextMessage.


public void onMessage (Message msg) {
        try {
            //  When a message is received, print it out to
            //  standard output
            TextMessage textmsg = (TextMessage)msg;
            System.out.println("Received : " + textmsg.getText() );
        } catch (JMSException e) {
            e.printStackTrace ();
        }
    }