Example usage for javax.jms Message getJMSCorrelationIDAsBytes

List of usage examples for javax.jms Message getJMSCorrelationIDAsBytes

Introduction

In this page you can find the example usage for javax.jms Message getJMSCorrelationIDAsBytes.

Prototype


byte[] getJMSCorrelationIDAsBytes() throws JMSException;

Source Link

Document

Gets the correlation ID as an array of bytes for the message.

Usage

From source file:com.jmstoolkit.beans.MessageTableModel.java

/**
 *
 * @param message/*from   w ww  .j av  a2 s . co  m*/
 */
@Override
public void onMessage(Message message) {
    LOGGER.log(Level.FINE, "Message Received");
    messagesReceived++;
    try {
        MessageTableRecord qRecord = new MessageTableRecord();
        qRecord.setJMSCorrelationID(message.getJMSCorrelationID());
        qRecord.setJMSDeliveryMode(message.getJMSDeliveryMode());
        qRecord.setJMSExpiration(message.getJMSExpiration());
        qRecord.setJMSMessageID(message.getJMSMessageID());
        qRecord.setJMSTimestamp(message.getJMSTimestamp());
        qRecord.setJMSType(message.getJMSType());
        qRecord.setJMSDestination(message.getJMSDestination());
        qRecord.setJMSCorrelationIDAsBytes(message.getJMSCorrelationIDAsBytes());
        qRecord.setJMSPriority(message.getJMSPriority());
        qRecord.setJMSType(message.getJMSType());
        qRecord.setJMSReplyTo(message.getJMSReplyTo());
        qRecord.setJMSRedelivered(message.getJMSRedelivered());
        Enumeration pEnumerator = message.getPropertyNames();
        Properties props = new Properties();
        while (pEnumerator.hasMoreElements()) {
            String pElement = (String) pEnumerator.nextElement();
            props.put(pElement, message.getStringProperty(pElement));
        }
        qRecord.setProperties(props);

        if (message instanceof TextMessage) {
            qRecord.setText(((TextMessage) message).getText());
        }
        if (message instanceof ObjectMessage) {
            qRecord.setObject(((ObjectMessage) message).getObject());
        }

        List newData = data;
        newData.add(qRecord);
        this.setData(newData);
    } catch (JMSException e) {
        LOGGER.log(Level.WARNING, "JMS problem", e);
    }
}