Example usage for javax.jms Message setJMSCorrelationID

List of usage examples for javax.jms Message setJMSCorrelationID

Introduction

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

Prototype


void setJMSCorrelationID(String correlationID) throws JMSException;

Source Link

Document

Sets the correlation ID for the message.

Usage

From source file:com.adaptris.core.jms.MessageTypeTranslatorCase.java

public void testMoveJmsHeadersJmsMessageToAdaptrisMessage() throws Exception {
    EmbeddedActiveMq broker = new EmbeddedActiveMq();
    MessageTypeTranslatorImp trans = createTranslator();
    try {//from  ww  w. j  a v  a2 s.com
        Session session = broker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE);
        Message jmsMsg = createMessage(session);
        jmsMsg.setJMSCorrelationID("ABC");
        jmsMsg.setJMSDeliveryMode(1);
        jmsMsg.setJMSPriority(4);
        addProperties(jmsMsg);
        long timestamp = System.currentTimeMillis();
        jmsMsg.setJMSTimestamp(timestamp);

        trans.setMoveJmsHeaders(true);
        start(trans, session);

        AdaptrisMessage msg = trans.translate(jmsMsg);
        assertMetadata(msg);
        assertEquals("ABC", msg.getMetadataValue(JmsConstants.JMS_CORRELATION_ID));
        assertEquals("1", msg.getMetadataValue(JmsConstants.JMS_DELIVERY_MODE));
        assertEquals("4", msg.getMetadataValue(JmsConstants.JMS_PRIORITY));
        assertEquals(String.valueOf(timestamp), msg.getMetadataValue(JmsConstants.JMS_TIMESTAMP));
    } finally {
        stop(trans);
        broker.destroy();
    }

}

From source file:org.logicblaze.lingo.jms.JmsClientInterceptor.java

protected void populateHeaders(Message requestMessage) throws JMSException {
    if (correlationID != null) {
        requestMessage.setJMSCorrelationID(correlationID);
    }/*from w  w w  . j a v a2 s  .c  o m*/
    if (jmsType != null) {
        requestMessage.setJMSType(jmsType);
    }
    if (jmsExpiration >= 0) {
        requestMessage.setJMSExpiration(jmsExpiration);
    }
    int jmsPriority = getJmsPriority();
    if (jmsPriority >= 0) {
        requestMessage.setJMSPriority(jmsPriority);
    }
    if (messageProperties != null) {
        for (Iterator iter = messageProperties.entrySet().iterator(); iter.hasNext();) {
            Map.Entry entry = (Map.Entry) iter.next();
            String name = entry.getKey().toString();
            Object value = entry.getValue();
            requestMessage.setObjectProperty(name, value);
        }
    }
}

From source file:org.nebulaframework.grid.cluster.manager.services.jobs.unbounded.UnboundedJobProcessor.java

/**
 * Enqueues a given Task with in the {@code TaskQueue}.
 * /*from  w  w  w. jav a  2s .  com*/
 * @param jobId
 *            String JobId
 * @param taskId
 *            int TaskId (Sequence Number of Task)
 * @param task
 *            {@code GridTask} task
 */
private void enqueueTask(final String jobId, final int taskId, GridTask<?> task) {

    String queueName = JMSNamingSupport.getTaskQueueName(jobId);

    // Post Process to include Meta Data
    MessagePostProcessor postProcessor = new MessagePostProcessor() {

        public Message postProcessMessage(Message message) throws JMSException {

            // Set Correlation ID to Job Id
            message.setJMSCorrelationID(jobId);

            // Put taskId as a property
            message.setIntProperty("taskId", taskId);

            log.debug("Enqueued Task : " + taskId);

            return message;
        }
    };

    // Send GridTask as a JMS Object Message to TaskQueue
    jmsTemplate.convertAndSend(queueName, task, postProcessor);

    // Update Task Tracker
    profile.getTaskTracker().taskEnqueued(taskId);

}

From source file:org.apache.servicemix.jms.endpoints.AbstractConsumerEndpoint.java

protected void setCorrelationId(Message query, Message reply) throws Exception {
    if (useMessageIdInResponse == null) {
        if (query.getJMSCorrelationID() != null) {
            reply.setJMSCorrelationID(query.getJMSCorrelationID());
        } else if (query.getJMSMessageID() != null) {
            reply.setJMSCorrelationID(query.getJMSMessageID());
        } else {//from w  w w . j a v  a  2 s  .c  o  m
            throw new IllegalStateException("No JMSCorrelationID or JMSMessageID set on query message");
        }
    } else if (useMessageIdInResponse.booleanValue()) {
        if (query.getJMSMessageID() != null) {
            reply.setJMSCorrelationID(query.getJMSMessageID());
        } else {
            throw new IllegalStateException("No JMSMessageID set on query message");
        }
    } else {
        if (query.getJMSCorrelationID() != null) {
            reply.setJMSCorrelationID(query.getJMSCorrelationID());
        } else {
            throw new IllegalStateException("No JMSCorrelationID set on query message");
        }
    }
}

From source file:org.apache.servicemix.jms.endpoints.JmsProviderEndpoint.java

/**
 * Process an InOnly or RobustInOnly exchange inside a JMS session.
 * This method delegates the JMS message creation to the marshaler and uses
 * the JMS template to send it.  If the JMS destination that was used to send
 * the message is not the default one, it synchronously wait for the message
 * to come back using a JMS selector.  Else, it just returns and the response
 * message will come back from the listener container.
 *
 * @param exchange//  w  ww  .j  a va 2 s .  co  m
 * @param in
 * @param session
 * @throws Exception
 */
protected void processInOutInSession(final MessageExchange exchange, final NormalizedMessage in,
        final Session session) throws Exception {
    // Create destinations
    final Destination dest = getDestination(exchange, in, session);
    final Destination replyDest = getReplyDestination(exchange, in, session);
    // Create message and send it
    final Message sendJmsMsg = marshaler.createMessage(exchange, in, session);
    sendJmsMsg.setJMSReplyTo(replyDest);
    // handle correlation ID
    String correlationId = sendJmsMsg.getJMSMessageID() != null ? sendJmsMsg.getJMSMessageID()
            : exchange.getExchangeId();
    sendJmsMsg.setJMSCorrelationID(correlationId);

    boolean asynchronous = replyDest.equals(replyDestination);

    if (asynchronous) {
        store.store(correlationId, exchange);
    }

    try {
        template.send(dest, new MessageCreator() {
            public Message createMessage(Session session) throws JMSException {
                return sendJmsMsg;
            }
        });
    } catch (Exception e) {
        if (asynchronous) {
            store.load(exchange.getExchangeId());
        }
        throw e;
    }

    if (!asynchronous) {
        // Create selector
        String jmsId = sendJmsMsg.getJMSMessageID();
        String selector = MSG_SELECTOR_START + jmsId + MSG_SELECTOR_END;
        // Receiving JMS Message, Creating and Returning NormalizedMessage out
        Message receiveJmsMsg = template.receiveSelected(replyDest, selector);
        if (receiveJmsMsg == null) {
            throw new IllegalStateException("Unable to receive response");
        }

        NormalizedMessage out = exchange.getMessage("out");
        if (out == null) {
            out = exchange.createMessage();
            exchange.setMessage(out, "out");
        }
        marshaler.populateMessage(receiveJmsMsg, exchange, out);
        boolean txSync = exchange.isTransacted()
                && Boolean.TRUE.equals(exchange.getProperty(JbiConstants.SEND_SYNC));
        if (txSync) {
            sendSync(exchange);
        } else {
            send(exchange);
        }
    }
}

From source file:com.mirth.connect.connectors.jms.transformers.AbstractJmsTransformer.java

/**
 * @param src The source data to compress
 * @return/*from  ww w . jav a 2 s .co  m*/
 * @throws TransformerException
 */
protected Message transformToMessage(Object src) throws TransformerException {
    try {
        // The session can be closed by the dispatcher closing so its more
        // reliable to get it from the dispatcher each time
        if (requireNewSession || getEndpoint() != null) {
            session = (Session) getEndpoint().getConnector().getDispatcher("transformerSession")
                    .getDelegateSession();
            requireNewSession = session == null;
        }

        Message msg = null;
        if (src instanceof Message) {
            msg = (Message) src;
            msg.clearProperties();
        } else {
            msg = JmsMessageUtils.getMessageForObject(src, session);
        }
        // set the event properties on the Message
        UMOEventContext ctx = RequestContext.getEventContext();
        if (ctx == null) {
            logger.warn("There is no current event context");
            return msg;
        }

        Map props = ctx.getProperties();
        props = PropertiesHelper.getPropertiesWithoutPrefix(props, "JMS");

        // FIXME: If we add the "destinations" property, then this message will be
        // ignored by channels that are not related to the original source
        // channel.
        // Bug: MIRTH-1689
        props.remove("destinations");

        Map.Entry entry;
        String key;
        for (Iterator iterator = props.entrySet().iterator(); iterator.hasNext();) {
            entry = (Map.Entry) iterator.next();
            key = entry.getKey().toString();
            if (MuleProperties.MULE_CORRELATION_ID_PROPERTY.equals(key)) {
                msg.setJMSCorrelationID(entry.getValue().toString());
            }
            //We dont want to set the ReplyTo property again as it will be set using JMSReplyTo
            if (!(MuleProperties.MULE_REPLY_TO_PROPERTY.equals(key)
                    && entry.getValue() instanceof Destination)) {
                try {
                    msg.setObjectProperty(encodeHeader(key), entry.getValue());
                } catch (JMSException e) {
                    //Various Jms servers have slightly different rules to what can be set as an object property on the message
                    //As such we have to take a hit n' hope approach
                    if (logger.isDebugEnabled())
                        logger.debug("Unable to set property '" + encodeHeader(key) + "' of type "
                                + entry.getValue().getClass().getName() + "': " + e.getMessage());
                }
            }
        }

        return msg;
        // }
    } catch (Exception e) {
        throw new TransformerException(this, e);
    }
}

From source file:hermes.impl.DefaultXMLHelper.java

public Message createMessage(MessageFactory hermes, XMLMessage message)
        throws JMSException, IOException, ClassNotFoundException, DecoderException {
    try {//w w  w  .ja  va  2  s  .c om
        Message rval = hermes.createMessage();

        if (message instanceof XMLTextMessage) {
            rval = hermes.createTextMessage();

            XMLTextMessage textMessage = (XMLTextMessage) message;
            TextMessage textRval = (TextMessage) rval;

            if (BASE64_CODEC.equals(textMessage.getCodec())) {
                byte[] bytes = base64EncoderTL.get().decode(textMessage.getText().getBytes());
                textRval.setText(new String(bytes, "ASCII"));
            } else {
                textRval.setText(textMessage.getText());
            }
        } else if (message instanceof XMLMapMessage) {
            rval = hermes.createMapMessage();

            XMLMapMessage mapMessage = (XMLMapMessage) message;
            MapMessage mapRval = (MapMessage) rval;

            for (Iterator iter = mapMessage.getBodyProperty().iterator(); iter.hasNext();) {
                final Property property = (Property) iter.next();

                if (property.getValue() == null) {
                    mapRval.setObject(property.getName(), null);
                } else if (property.getType().equals(String.class.getName())) {
                    mapRval.setString(property.getName(), property.getValue());
                } else if (property.getType().equals(Long.class.getName())) {
                    mapRval.setLong(property.getName(), Long.parseLong(property.getValue()));
                } else if (property.getType().equals(Double.class.getName())) {
                    mapRval.setDouble(property.getName(), Double.parseDouble(property.getValue()));
                } else if (property.getType().equals(Boolean.class.getName())) {
                    mapRval.setBoolean(property.getName(), Boolean.getBoolean(property.getValue()));
                } else if (property.getType().equals(Character.class.getName())) {
                    mapRval.setChar(property.getName(), property.getValue().charAt(0));
                } else if (property.getType().equals(Short.class.getName())) {
                    mapRval.setShort(property.getName(), Short.parseShort(property.getValue()));
                } else if (property.getType().equals(Integer.class.getName())) {
                    mapRval.setInt(property.getName(), Integer.parseInt(property.getValue()));
                }
            }
        } else if (message instanceof XMLBytesMessage) {
            rval = hermes.createBytesMessage();

            XMLBytesMessage bytesMessage = (XMLBytesMessage) message;
            BytesMessage bytesRval = (BytesMessage) rval;

            bytesRval.writeBytes(base64EncoderTL.get().decode(bytesMessage.getBytes().getBytes()));
        } else if (message instanceof XMLObjectMessage) {
            rval = hermes.createObjectMessage();

            XMLObjectMessage objectMessage = (XMLObjectMessage) message;
            ObjectMessage objectRval = (ObjectMessage) rval;
            ByteArrayInputStream bistream = new ByteArrayInputStream(
                    base64EncoderTL.get().decode(objectMessage.getObject().getBytes()));

            ObjectInputStream oistream = new ObjectInputStream(bistream);

            objectRval.setObject((Serializable) oistream.readObject());
        }

        //
        // JMS Header properties

        try {
            rval.setJMSDeliveryMode(message.getJMSDeliveryMode());
        } catch (JMSException ex) {
            log.error("unable to set JMSDeliveryMode to " + message.getJMSDeliveryMode() + ": "
                    + ex.getMessage());
        }

        try {
            rval.setJMSMessageID(message.getJMSMessageID());
        } catch (JMSException ex) {
            log.error("unable to set JMSMessageID: " + ex.getMessage(), ex);
        }

        try {
            if (message.getJMSExpiration() != null) {
                rval.setJMSExpiration(message.getJMSExpiration());
            }
        } catch (JMSException ex) {
            log.error("unable to set JMSExpiration: " + ex.getMessage(), ex);
        }

        try {
            if (message.getJMSPriority() != null) {
                rval.setJMSPriority(message.getJMSPriority());
            }
        } catch (JMSException ex) {
            log.error("unable to set JMSPriority: " + ex.getMessage(), ex);
        }

        try {
            if (message.getJMSTimestamp() != null) {
                rval.setJMSTimestamp(message.getJMSTimestamp());
            }
        } catch (JMSException ex) {
            log.error("unable to set JMSTimestamp:" + ex.getMessage(), ex);
        }

        if (message.getJMSCorrelationID() != null) {
            rval.setJMSCorrelationID(message.getJMSCorrelationID());
        }

        if (message.getJMSReplyTo() != null && !message.getJMSReplyTo().equals("null")) {
            rval.setJMSReplyTo(hermes.getDestination(message.getJMSReplyTo(),
                    Domain.getDomain(message.getJMSReplyToDomain())));
        }

        if (message.getJMSType() != null) {
            rval.setJMSType(message.getJMSType());
        }

        if (message.getJMSDestination() != null) {
            if (message.isFromQueue()) {
                rval.setJMSDestination(hermes.getDestination(message.getJMSDestination(), Domain.QUEUE));
            } else {
                rval.setJMSDestination(hermes.getDestination(message.getJMSDestination(), Domain.TOPIC));
            }
        }

        for (Iterator iter = message.getHeaderProperty().iterator(); iter.hasNext();) {
            Property property = (Property) iter.next();

            if (property.getValue() == null) {
                rval.setObjectProperty(property.getName(), null);
            } else if (property.getType().equals(String.class.getName())) {
                rval.setStringProperty(property.getName(), StringEscapeUtils.unescapeXml(property.getValue()));
            } else if (property.getType().equals(Long.class.getName())) {
                rval.setLongProperty(property.getName(), Long.parseLong(property.getValue()));
            } else if (property.getType().equals(Double.class.getName())) {
                rval.setDoubleProperty(property.getName(), Double.parseDouble(property.getValue()));
            } else if (property.getType().equals(Boolean.class.getName())) {
                rval.setBooleanProperty(property.getName(), Boolean.parseBoolean(property.getValue()));
            } else if (property.getType().equals(Short.class.getName())) {
                rval.setShortProperty(property.getName(), Short.parseShort(property.getValue()));
            } else if (property.getType().equals(Integer.class.getName())) {
                rval.setIntProperty(property.getName(), Integer.parseInt(property.getValue()));
            }
        }

        return rval;
    } catch (NamingException e) {
        throw new HermesException(e);
    }

}

From source file:net.timewalker.ffmq4.admin.RemoteAdministrationThread.java

@Override
public void run() {
    log.info("Starting remote administration thread ...");

    try {/* www.j av  a  2  s.  c o m*/
        LocalQueue inputQueue = engine.getLocalQueue(FFMQConstants.ADM_REQUEST_QUEUE);
        LocalQueue outputQueue = engine.getLocalQueue(FFMQConstants.ADM_REPLY_QUEUE);

        conn = new LocalQueueConnection(engine, null, null);
        session = conn.createQueueSession(true, Session.SESSION_TRANSACTED);
        receiver = session.createReceiver(inputQueue);
        sender = session.createSender(outputQueue);

        conn.start();

        // Flush input queue on startup
        inputQueue.purge(null);
        outputQueue.purge(null);

        // Enter listening loop
        notifyStartup();
        while (!stopRequired) {
            Message message = receiver.receive();
            if (message == null)
                break; // Interrupted
            log.debug("Received message " + message);

            try {
                // Process the command
                String errorMsg = process(message);

                // Build response message
                Message response = session.createMessage();
                response.setJMSCorrelationID(message.getJMSMessageID());
                if (errorMsg != null)
                    response.setStringProperty(FFMQAdminConstants.ADM_HEADER_ERRMSG, errorMsg);

                sender.send(response, DeliveryMode.NON_PERSISTENT, Message.DEFAULT_PRIORITY,
                        Message.DEFAULT_TIME_TO_LIVE);
            } catch (JMSException e) {
                log.error("Cannot process admin command", e);
            } finally {
                session.commit();
            }
        }

        log.debug("Remote administration thread has stopped");
    } catch (Throwable e) {
        log.fatal("Administration thread failed", e);
        notifyStartup();
    } finally {
        try {
            if (sender != null)
                sender.close();
        } catch (JMSException e) {
            ErrorTools.log(e, log);
        }

        try {
            if (receiver != null)
                receiver.close();
        } catch (JMSException e) {
            ErrorTools.log(e, log);
        }

        try {
            if (session != null)
                session.close();
        } catch (JMSException e) {
            ErrorTools.log(e, log);
        }

        try {
            if (conn != null)
                conn.close();
        } catch (JMSException e) {
            ErrorTools.log(e, log);
        }
    }
}

From source file:org.apache.axis2.transport.jms.JMSSender.java

/**
 * Create a JMS Message from the given MessageContext and using the given
 * session/*from   w  w w  .j  a v  a  2  s .  c  o  m*/
 *
 * @param msgContext the MessageContext
 * @param session    the JMS session
 * @param contentTypeProperty the message property to be used to store the
 *                            content type
 * @return a JMS message from the context and session
 * @throws JMSException on exception
 * @throws AxisFault on exception
 */
private Message createJMSMessage(MessageContext msgContext, Session session, String contentTypeProperty)
        throws JMSException, AxisFault {

    Message message = null;
    String msgType = getProperty(msgContext, JMSConstants.JMS_MESSAGE_TYPE);

    // check the first element of the SOAP body, do we have content wrapped using the
    // default wrapper elements for binary (BaseConstants.DEFAULT_BINARY_WRAPPER) or
    // text (BaseConstants.DEFAULT_TEXT_WRAPPER) ? If so, do not create SOAP messages
    // for JMS but just get the payload in its native format
    String jmsPayloadType = guessMessageType(msgContext);

    if (jmsPayloadType == null) {

        OMOutputFormat format = BaseUtils.getOMOutputFormat(msgContext);
        MessageFormatter messageFormatter = null;
        try {
            messageFormatter = TransportUtils.getMessageFormatter(msgContext);
        } catch (AxisFault axisFault) {
            throw new JMSException("Unable to get the message formatter to use");
        }

        String contentType = messageFormatter.getContentType(msgContext, format, msgContext.getSoapAction());

        boolean useBytesMessage = msgType != null && JMSConstants.JMS_BYTE_MESSAGE.equals(msgType)
                || contentType.indexOf(HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED) > -1;

        OutputStream out;
        StringWriter sw;
        if (useBytesMessage) {
            BytesMessage bytesMsg = session.createBytesMessage();
            sw = null;
            out = new BytesMessageOutputStream(bytesMsg);
            message = bytesMsg;
        } else {
            sw = new StringWriter();
            try {
                out = new WriterOutputStream(sw, format.getCharSetEncoding());
            } catch (UnsupportedCharsetException ex) {
                handleException("Unsupported encoding " + format.getCharSetEncoding(), ex);
                return null;
            }
        }

        try {
            messageFormatter.writeTo(msgContext, format, out, true);
            out.close();
        } catch (IOException e) {
            handleException("IO Error while creating BytesMessage", e);
        }

        if (!useBytesMessage) {
            TextMessage txtMsg = session.createTextMessage();
            txtMsg.setText(sw.toString());
            message = txtMsg;
        }

        if (contentTypeProperty != null) {
            message.setStringProperty(contentTypeProperty, contentType);
        }

    } else if (JMSConstants.JMS_BYTE_MESSAGE.equals(jmsPayloadType)) {
        message = session.createBytesMessage();
        BytesMessage bytesMsg = (BytesMessage) message;
        OMElement wrapper = msgContext.getEnvelope().getBody()
                .getFirstChildWithName(BaseConstants.DEFAULT_BINARY_WRAPPER);
        OMNode omNode = wrapper.getFirstOMChild();
        if (omNode != null && omNode instanceof OMText) {
            Object dh = ((OMText) omNode).getDataHandler();
            if (dh != null && dh instanceof DataHandler) {
                try {
                    ((DataHandler) dh).writeTo(new BytesMessageOutputStream(bytesMsg));
                } catch (IOException e) {
                    handleException("Error serializing binary content of element : "
                            + BaseConstants.DEFAULT_BINARY_WRAPPER, e);
                }
            }
        }

    } else if (JMSConstants.JMS_TEXT_MESSAGE.equals(jmsPayloadType)) {
        message = session.createTextMessage();
        TextMessage txtMsg = (TextMessage) message;
        txtMsg.setText(msgContext.getEnvelope().getBody()
                .getFirstChildWithName(BaseConstants.DEFAULT_TEXT_WRAPPER).getText());
    }

    // set the JMS correlation ID if specified
    String correlationId = getProperty(msgContext, JMSConstants.JMS_COORELATION_ID);
    if (correlationId == null && msgContext.getRelatesTo() != null) {
        correlationId = msgContext.getRelatesTo().getValue();
    }

    if (correlationId != null) {
        message.setJMSCorrelationID(correlationId);
    }

    if (msgContext.isServerSide()) {
        // set SOAP Action as a property on the JMS message
        setProperty(message, msgContext, BaseConstants.SOAPACTION);
    } else {
        String action = msgContext.getOptions().getAction();
        if (action != null) {
            message.setStringProperty(BaseConstants.SOAPACTION, action);
        }
    }

    JMSUtils.setTransportHeaders(msgContext, message);
    return message;
}

From source file:org.apache.axis2.transport.jms.JMSUtils.java

/**
 * Set transport headers from the axis message context, into the JMS message
 *
 * @param msgContext the axis message context
 * @param message the JMS Message//www. j av  a  2  s.  c  o m
 * @throws JMSException on exception
 */
public static void setTransportHeaders(MessageContext msgContext, Message message) throws JMSException {

    Map<?, ?> headerMap = (Map<?, ?>) msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);

    if (headerMap == null) {
        return;
    }

    for (Object headerName : headerMap.keySet()) {

        String name = (String) headerName;

        if (name.startsWith(JMSConstants.JMSX_PREFIX)
                && !(name.equals(JMSConstants.JMSX_GROUP_ID) || name.equals(JMSConstants.JMSX_GROUP_SEQ))) {
            continue;
        }

        if (JMSConstants.JMS_COORELATION_ID.equals(name)) {
            message.setJMSCorrelationID((String) headerMap.get(JMSConstants.JMS_COORELATION_ID));
        } else if (JMSConstants.JMS_DELIVERY_MODE.equals(name)) {
            Object o = headerMap.get(JMSConstants.JMS_DELIVERY_MODE);
            if (o instanceof Integer) {
                message.setJMSDeliveryMode((Integer) o);
            } else if (o instanceof String) {
                try {
                    message.setJMSDeliveryMode(Integer.parseInt((String) o));
                } catch (NumberFormatException nfe) {
                    log.warn("Invalid delivery mode ignored : " + o, nfe);
                }
            } else {
                log.warn("Invalid delivery mode ignored : " + o);
            }

        } else if (JMSConstants.JMS_EXPIRATION.equals(name)) {
            message.setJMSExpiration(Long.parseLong((String) headerMap.get(JMSConstants.JMS_EXPIRATION)));
        } else if (JMSConstants.JMS_MESSAGE_ID.equals(name)) {
            message.setJMSMessageID((String) headerMap.get(JMSConstants.JMS_MESSAGE_ID));
        } else if (JMSConstants.JMS_PRIORITY.equals(name)) {
            message.setJMSPriority(Integer.parseInt((String) headerMap.get(JMSConstants.JMS_PRIORITY)));
        } else if (JMSConstants.JMS_TIMESTAMP.equals(name)) {
            message.setJMSTimestamp(Long.parseLong((String) headerMap.get(JMSConstants.JMS_TIMESTAMP)));
        } else if (JMSConstants.JMS_MESSAGE_TYPE.equals(name)) {
            message.setJMSType((String) headerMap.get(JMSConstants.JMS_MESSAGE_TYPE));

        } else {
            Object value = headerMap.get(name);
            if (value instanceof String) {
                message.setStringProperty(name, (String) value);
            } else if (value instanceof Boolean) {
                message.setBooleanProperty(name, (Boolean) value);
            } else if (value instanceof Integer) {
                message.setIntProperty(name, (Integer) value);
            } else if (value instanceof Long) {
                message.setLongProperty(name, (Long) value);
            } else if (value instanceof Double) {
                message.setDoubleProperty(name, (Double) value);
            } else if (value instanceof Float) {
                message.setFloatProperty(name, (Float) value);
            }
        }
    }
}