Search in sources :

Example 1 with JmsTextMessage

use of org.apache.qpid.jms.message.JmsTextMessage in project syndesis-qe by syndesisio.

the class JMSUtils method getMessageText.

public static String getMessageText(String appName, String jmsProtocol, String user, String pass, Destination type, String destinationName) {
    Message m = getMessage(appName, jmsProtocol, user, pass, type, destinationName, 60000L);
    if (m == null) {
        return null;
    }
    String text = null;
    try {
        if (m instanceof JmsTextMessage) {
            text = ((JmsTextMessage) m).getText();
        } else if (m instanceof ActiveMQBytesMessage) {
            text = new String(((ActiveMQBytesMessage) m).getContent().getData());
        } else {
            text = ((ActiveMQTextMessage) m).getText();
        }
    } catch (JMSException e) {
        log.error("Unable to get text from message", e);
        e.printStackTrace();
    }
    log.debug("Got message: " + text);
    return text;
}
Also used : ActiveMQBytesMessage(org.apache.activemq.command.ActiveMQBytesMessage) JmsTextMessage(org.apache.qpid.jms.message.JmsTextMessage) Message(javax.jms.Message) ActiveMQTextMessage(org.apache.activemq.command.ActiveMQTextMessage) ActiveMQBytesMessage(org.apache.activemq.command.ActiveMQBytesMessage) JMSException(javax.jms.JMSException) JmsTextMessage(org.apache.qpid.jms.message.JmsTextMessage) ActiveMQTextMessage(org.apache.activemq.command.ActiveMQTextMessage)

Aggregations

JMSException (javax.jms.JMSException)1 Message (javax.jms.Message)1 ActiveMQBytesMessage (org.apache.activemq.command.ActiveMQBytesMessage)1 ActiveMQTextMessage (org.apache.activemq.command.ActiveMQTextMessage)1 JmsTextMessage (org.apache.qpid.jms.message.JmsTextMessage)1