Example usage for javax.jms Message getJMSTimestamp

List of usage examples for javax.jms Message getJMSTimestamp

Introduction

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

Prototype


long getJMSTimestamp() throws JMSException;

Source Link

Document

Gets the message timestamp.

Usage

From source file:nl.nn.adapterframework.unmanaged.SpringJmsConnector.java

public void onMessage(Message message, Session session) throws JMSException {
    TransactionStatus txStatus = null;//from w w w.j  a  va2s .  c  o  m

    long onMessageStart = System.currentTimeMillis();
    long jmsTimestamp = message.getJMSTimestamp();
    threadsProcessing.increase();
    Thread.currentThread().setName(getReceiver().getName() + "[" + threadsProcessing.getValue() + "]");

    try {
        if (TX != null) {
            txStatus = txManager.getTransaction(TX);
        }

        Map threadContext = new HashMap();
        try {
            IPortConnectedListener listener = getListener();
            threadContext.put(THREAD_CONTEXT_SESSION_KEY, session);
            //            if (log.isDebugEnabled()) log.debug("transaction status before: "+JtaUtil.displayTransactionStatus());
            getReceiver().processRawMessage(listener, message, threadContext);
            //            if (log.isDebugEnabled()) log.debug("transaction status after: "+JtaUtil.displayTransactionStatus());
        } catch (ListenerException e) {
            getReceiver().increaseRetryIntervalAndWait(e, getLogPrefix());
            if (txStatus != null) {
                txStatus.setRollbackOnly();
            }
        } finally {
            if (txStatus == null && jmsContainer.isSessionTransacted()) {
                log.debug(getLogPrefix() + "committing JMS session");
                session.commit();
            }
        }
    } finally {
        if (txStatus != null) {
            txManager.commit(txStatus);
        }
        threadsProcessing.decrease();
        if (log.isInfoEnabled()) {
            long onMessageEnd = System.currentTimeMillis();

            log.info(getLogPrefix() + "A) JMSMessageTime [" + DateUtils.format(jmsTimestamp) + "]");
            log.info(getLogPrefix() + "B) onMessageStart [" + DateUtils.format(onMessageStart)
                    + "] diff (~'queing' time) [" + (onMessageStart - jmsTimestamp) + "]");
            log.info(getLogPrefix() + "C) onMessageEnd   [" + DateUtils.format(onMessageEnd)
                    + "] diff (process time) [" + (onMessageEnd - onMessageStart) + "]");
        }

        //         boolean simulateCrashAfterCommit=true;
        //         if (simulateCrashAfterCommit) {
        //            toggle=!toggle;
        //            if (toggle) {
        //               JtaUtil.setRollbackOnly();
        //               throw new JMSException("simulate crash just before final commit");
        //            }
        //         }
    }
}

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

/**
 * Process a new message received/*from  w  ww.  jav a  2s . c  om*/
 *
 * @param message the JMS message received
 * @param ut      UserTransaction which was used to receive the message
 * @return true if caller should commit
 */
public boolean onMessage(Message message, UserTransaction ut) {

    try {
        if (log.isDebugEnabled()) {
            StringBuffer sb = new StringBuffer();
            sb.append("Received new JMS message for service :").append(endpoint.getServiceName());
            sb.append("\nDestination    : ").append(message.getJMSDestination());
            sb.append("\nMessage ID     : ").append(message.getJMSMessageID());
            sb.append("\nCorrelation ID : ").append(message.getJMSCorrelationID());
            sb.append("\nReplyTo        : ").append(message.getJMSReplyTo());
            sb.append("\nRedelivery ?   : ").append(message.getJMSRedelivered());
            sb.append("\nPriority       : ").append(message.getJMSPriority());
            sb.append("\nExpiration     : ").append(message.getJMSExpiration());
            sb.append("\nTimestamp      : ").append(message.getJMSTimestamp());
            sb.append("\nMessage Type   : ").append(message.getJMSType());
            sb.append("\nPersistent ?   : ").append(DeliveryMode.PERSISTENT == message.getJMSDeliveryMode());

            log.debug(sb.toString());
            if (log.isTraceEnabled() && message instanceof TextMessage) {
                log.trace("\nMessage : " + ((TextMessage) message).getText());
            }
        }
    } catch (JMSException e) {
        if (log.isDebugEnabled()) {
            log.debug("Error reading JMS message headers for debug logging", e);
        }
    }

    // update transport level metrics
    try {
        metrics.incrementBytesReceived(JMSUtils.getMessageSize(message));
    } catch (JMSException e) {
        log.warn("Error reading JMS message size to update transport metrics", e);
    }

    // has this message already expired? expiration time == 0 means never expires
    // TODO: explain why this is necessary; normally it is the responsibility of the provider to handle message expiration
    try {
        long expiryTime = message.getJMSExpiration();
        if (expiryTime > 0 && System.currentTimeMillis() > expiryTime) {
            if (log.isDebugEnabled()) {
                log.debug("Discard expired message with ID : " + message.getJMSMessageID());
            }
            return true;
        }
    } catch (JMSException ignore) {
    }

    boolean successful = false;
    try {
        successful = processThoughEngine(message, ut);

    } catch (JMSException e) {
        log.error("JMS Exception encountered while processing", e);
    } catch (AxisFault e) {
        log.error("Axis fault processing message", e);
    } catch (Exception e) {
        log.error("Unknown error processing message", e);

    } finally {
        if (successful) {
            metrics.incrementMessagesReceived();
        } else {
            metrics.incrementFaultsReceiving();
        }
    }

    return successful;
}

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

/**
 * Extract transport level headers for JMS from the given message into a Map
 *
 * @param message the JMS message//from  w  w w.  ja v  a 2 s  .c om
 * @return a Map of the transport headers
 */
public static Map<String, Object> getTransportHeaders(Message message) {
    // create a Map to hold transport headers
    Map<String, Object> map = new HashMap<String, Object>();

    // correlation ID
    try {
        if (message.getJMSCorrelationID() != null) {
            map.put(JMSConstants.JMS_COORELATION_ID, message.getJMSCorrelationID());
        }
    } catch (JMSException ignore) {
    }

    // set the delivery mode as persistent or not
    try {
        map.put(JMSConstants.JMS_DELIVERY_MODE, Integer.toString(message.getJMSDeliveryMode()));
    } catch (JMSException ignore) {
    }

    // destination name
    try {
        if (message.getJMSDestination() != null) {
            Destination dest = message.getJMSDestination();
            map.put(JMSConstants.JMS_DESTINATION,
                    dest instanceof Queue ? ((Queue) dest).getQueueName() : ((Topic) dest).getTopicName());
        }
    } catch (JMSException ignore) {
    }

    // expiration
    try {
        map.put(JMSConstants.JMS_EXPIRATION, Long.toString(message.getJMSExpiration()));
    } catch (JMSException ignore) {
    }

    // if a JMS message ID is found
    try {
        if (message.getJMSMessageID() != null) {
            map.put(JMSConstants.JMS_MESSAGE_ID, message.getJMSMessageID());
        }
    } catch (JMSException ignore) {
    }

    // priority
    try {
        map.put(JMSConstants.JMS_PRIORITY, Long.toString(message.getJMSPriority()));
    } catch (JMSException ignore) {
    }

    // redelivered
    try {
        map.put(JMSConstants.JMS_REDELIVERED, Boolean.toString(message.getJMSRedelivered()));
    } catch (JMSException ignore) {
    }

    // replyto destination name
    try {
        if (message.getJMSReplyTo() != null) {
            Destination dest = message.getJMSReplyTo();
            map.put(JMSConstants.JMS_REPLY_TO,
                    dest instanceof Queue ? ((Queue) dest).getQueueName() : ((Topic) dest).getTopicName());
        }
    } catch (JMSException ignore) {
    }

    // priority
    try {
        map.put(JMSConstants.JMS_TIMESTAMP, Long.toString(message.getJMSTimestamp()));
    } catch (JMSException ignore) {
    }

    // message type
    try {
        if (message.getJMSType() != null) {
            map.put(JMSConstants.JMS_TYPE, message.getJMSType());
        }
    } catch (JMSException ignore) {
    }

    // any other transport properties / headers
    Enumeration<?> e = null;
    try {
        e = message.getPropertyNames();
    } catch (JMSException ignore) {
    }

    if (e != null) {
        while (e.hasMoreElements()) {
            String headerName = (String) e.nextElement();
            try {
                map.put(headerName, message.getStringProperty(headerName));
                continue;
            } catch (JMSException ignore) {
            }
            try {
                map.put(headerName, message.getBooleanProperty(headerName));
                continue;
            } catch (JMSException ignore) {
            }
            try {
                map.put(headerName, message.getIntProperty(headerName));
                continue;
            } catch (JMSException ignore) {
            }
            try {
                map.put(headerName, message.getLongProperty(headerName));
                continue;
            } catch (JMSException ignore) {
            }
            try {
                map.put(headerName, message.getDoubleProperty(headerName));
                continue;
            } catch (JMSException ignore) {
            }
            try {
                map.put(headerName, message.getFloatProperty(headerName));
            } catch (JMSException ignore) {
            }
        }
    }

    return map;
}

From source file:org.apache.camel.component.jms.JmsBinding.java

public Map<String, Object> extractHeadersFromJms(Message jmsMessage, Exchange exchange) {
    Map<String, Object> map = new HashMap<String, Object>();
    if (jmsMessage != null) {
        // lets populate the standard JMS message headers
        try {// w  w w  . j  a v a 2 s . co m
            map.put("JMSCorrelationID", jmsMessage.getJMSCorrelationID());
            map.put("JMSDeliveryMode", jmsMessage.getJMSDeliveryMode());
            map.put("JMSDestination", jmsMessage.getJMSDestination());
            map.put("JMSExpiration", jmsMessage.getJMSExpiration());
            map.put("JMSMessageID", jmsMessage.getJMSMessageID());
            map.put("JMSPriority", jmsMessage.getJMSPriority());
            map.put("JMSRedelivered", jmsMessage.getJMSRedelivered());
            map.put("JMSTimestamp", jmsMessage.getJMSTimestamp());

            // to work around OracleAQ not supporting the JMSReplyTo header (CAMEL-2909)
            try {
                map.put("JMSReplyTo", jmsMessage.getJMSReplyTo());
            } catch (JMSException e) {
                LOG.trace("Cannot read JMSReplyTo header. Will ignore this exception.", e);
            }
            // to work around OracleAQ not supporting the JMSType header (CAMEL-2909)
            try {
                map.put("JMSType", jmsMessage.getJMSType());
            } catch (JMSException e) {
                LOG.trace("Cannot read JMSType header. Will ignore this exception.", e);
            }

            // this works around a bug in the ActiveMQ property handling
            map.put("JMSXGroupID", jmsMessage.getStringProperty("JMSXGroupID"));
        } catch (JMSException e) {
            throw new RuntimeCamelException(e);
        }

        Enumeration names;
        try {
            names = jmsMessage.getPropertyNames();
        } catch (JMSException e) {
            throw new RuntimeCamelException(e);
        }
        while (names.hasMoreElements()) {
            String name = names.nextElement().toString();
            try {
                Object value = jmsMessage.getObjectProperty(name);
                if (headerFilterStrategy != null
                        && headerFilterStrategy.applyFilterToExternalHeaders(name, value, exchange)) {
                    continue;
                }

                // must decode back from safe JMS header name to original header name
                // when storing on this Camel JmsMessage object.
                String key = jmsKeyFormatStrategy.decodeKey(name);
                map.put(key, value);
            } catch (JMSException e) {
                throw new RuntimeCamelException(name, e);
            }
        }
    }

    return map;
}

From source file:org.apache.qpid.systest.management.jmx.QueueManagementTest.java

/**
 * Tests {@link ManagedQueue#viewMessages(long, long)} interface.
 */// ww w  .  ja v a 2 s. c o m
public void testViewSingleMessage() throws Exception {
    final List<Message> sentMessages = sendMessage(_session, _sourceQueue, 1);
    syncSession(_session);
    final Message sentMessage = sentMessages.get(0);

    assertEquals("Unexpected queue depth", 1, _managedSourceQueue.getMessageCount().intValue());

    // Check the contents of the message
    final TabularData tab = _managedSourceQueue.viewMessages(1l, 1l);
    assertEquals("Unexpected number of rows in table", 1, tab.size());
    final Iterator<CompositeData> rowItr = (Iterator<CompositeData>) tab.values().iterator();

    final CompositeData row1 = rowItr.next();
    assertNotNull("Message should have AMQ message id", row1.get(ManagedQueue.MSG_AMQ_ID));
    assertEquals("Unexpected queue position", 1l, row1.get(ManagedQueue.MSG_QUEUE_POS));
    assertEquals("Unexpected redelivered flag", Boolean.FALSE, row1.get(ManagedQueue.MSG_REDELIVERED));

    // Check the contents of header (encoded in a string array)
    final String[] headerArray = (String[]) row1.get(ManagedQueue.MSG_HEADER);
    assertNotNull("Expected message header array", headerArray);
    final Map<String, String> headers = headerArrayToMap(headerArray);

    final String expectedJMSMessageID = isBroker010() ? sentMessage.getJMSMessageID().replace("ID:", "")
            : sentMessage.getJMSMessageID();
    final String expectedFormattedJMSTimestamp = FastDateFormat
            .getInstance(ManagedQueue.JMSTIMESTAMP_DATETIME_FORMAT).format(sentMessage.getJMSTimestamp());
    assertEquals("Unexpected JMSMessageID within header", expectedJMSMessageID, headers.get("JMSMessageID"));
    assertEquals("Unexpected JMSPriority within header", String.valueOf(sentMessage.getJMSPriority()),
            headers.get("JMSPriority"));
    assertEquals("Unexpected JMSTimestamp within header", expectedFormattedJMSTimestamp,
            headers.get("JMSTimestamp"));
}

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

/**
 * Extract transport level headers for JMS from the given message into a Map
 *
 * @param message the JMS message//  w w w . j  a v a  2s  .c  om
 * @return a Map of the transport headers
 */
public static Map getTransportHeaders(Message message) {
    // create a Map to hold transport headers
    Map map = new HashMap();

    // correlation ID
    try {
        if (message.getJMSCorrelationID() != null) {
            map.put(JMSConstants.JMS_COORELATION_ID, message.getJMSCorrelationID());
        }
    } catch (JMSException ignore) {
    }

    // set the delivery mode as persistent or not
    try {
        map.put(JMSConstants.JMS_DELIVERY_MODE, Integer.toString(message.getJMSDeliveryMode()));
    } catch (JMSException ignore) {
    }

    // destination name
    try {
        if (message.getJMSDestination() != null) {
            Destination dest = message.getJMSDestination();
            map.put(JMSConstants.JMS_DESTINATION,
                    dest instanceof Queue ? ((Queue) dest).getQueueName() : ((Topic) dest).getTopicName());
        }
    } catch (JMSException ignore) {
    }

    // expiration
    try {
        map.put(JMSConstants.JMS_EXPIRATION, Long.toString(message.getJMSExpiration()));
    } catch (JMSException ignore) {
    }

    // if a JMS message ID is found
    try {
        if (message.getJMSMessageID() != null) {
            map.put(JMSConstants.JMS_MESSAGE_ID, message.getJMSMessageID());
        }
    } catch (JMSException ignore) {
    }

    // priority
    try {
        map.put(JMSConstants.JMS_PRIORITY, Long.toString(message.getJMSPriority()));
    } catch (JMSException ignore) {
    }

    // redelivered
    try {
        map.put(JMSConstants.JMS_REDELIVERED, Boolean.toString(message.getJMSRedelivered()));
    } catch (JMSException ignore) {
    }

    // replyto destination name
    try {
        if (message.getJMSReplyTo() != null) {
            Destination dest = message.getJMSReplyTo();
            map.put(JMSConstants.JMS_REPLY_TO,
                    dest instanceof Queue ? ((Queue) dest).getQueueName() : ((Topic) dest).getTopicName());
        }
    } catch (JMSException ignore) {
    }

    // priority
    try {
        map.put(JMSConstants.JMS_TIMESTAMP, Long.toString(message.getJMSTimestamp()));
    } catch (JMSException ignore) {
    }

    // message type
    try {
        if (message.getJMSType() != null) {
            map.put(JMSConstants.JMS_TYPE, message.getJMSType());
        }
    } catch (JMSException ignore) {
    }

    // any other transport properties / headers
    Enumeration e = null;
    try {
        e = message.getPropertyNames();
    } catch (JMSException ignore) {
    }

    if (e != null) {
        while (e.hasMoreElements()) {
            String headerName = (String) e.nextElement();
            try {
                map.put(headerName, message.getStringProperty(headerName));
                continue;
            } catch (JMSException ignore) {
            }
            try {
                map.put(headerName, Boolean.valueOf(message.getBooleanProperty(headerName)));
                continue;
            } catch (JMSException ignore) {
            }
            try {
                map.put(headerName, new Integer(message.getIntProperty(headerName)));
                continue;
            } catch (JMSException ignore) {
            }
            try {
                map.put(headerName, new Long(message.getLongProperty(headerName)));
                continue;
            } catch (JMSException ignore) {
            }
            try {
                map.put(headerName, new Double(message.getDoubleProperty(headerName)));
                continue;
            } catch (JMSException ignore) {
            }
            try {
                map.put(headerName, new Float(message.getFloatProperty(headerName)));
                continue;
            } catch (JMSException ignore) {
            }
        }
    }

    return map;
}

From source file:org.codehaus.stomp.jms.StompSession.java

protected void copyStandardHeadersFromMessageToFrame(Message message, StompFrame command) throws JMSException {
    final Map headers = command.getHeaders();
    headers.put(Stomp.Headers.Message.DESTINATION, convertDestination(message.getJMSDestination()));
    headers.put(Stomp.Headers.Message.MESSAGE_ID, message.getJMSMessageID());

    if (message.getJMSCorrelationID() != null) {
        headers.put(Stomp.Headers.Message.CORRELATION_ID, message.getJMSCorrelationID());
    }/*from   w  w  w.ja v a  2s . c  om*/
    headers.put(Stomp.Headers.Message.EXPIRATION_TIME, "" + message.getJMSExpiration());

    if (message.getJMSRedelivered()) {
        headers.put(Stomp.Headers.Message.REDELIVERED, "true");
    }
    headers.put(Stomp.Headers.Message.PRORITY, "" + message.getJMSPriority());

    if (message.getJMSReplyTo() != null) {
        headers.put(Stomp.Headers.Message.REPLY_TO, convertDestination(message.getJMSReplyTo()));
    }
    headers.put(Stomp.Headers.Message.TIMESTAMP, "" + message.getJMSTimestamp());

    if (message.getJMSType() != null) {
        headers.put(Stomp.Headers.Message.TYPE, message.getJMSType());
    }

    // now lets add all the message headers
    Enumeration names = message.getPropertyNames();
    while (names.hasMoreElements()) {
        String name = (String) names.nextElement();
        Object value = message.getObjectProperty(name);
        headers.put(name, value);
    }
}

From source file:org.mitre.mpf.markup.MarkupRequestConsumer.java

public void onMessage(Message message) {
    Stopwatch stopwatch = Stopwatch.createStarted();

    if (message == null) {
        log.warn("Received a null JMS message. No action will be taken.");
        return;//from www .j  a v  a2s. c  om
    }

    if (!(message instanceof BytesMessage)) {
        log.warn("Received a JMS message, but it was not of the correct type. No action will be taken.");
        return;
    }

    try {
        log.info("Received JMS message. Type = {}. JMS Message ID = {}. JMS Correlation ID = {}.",
                message.getClass().getName(), message.getJMSMessageID(), message.getJMSCorrelationID());

        final Map<String, Object> requestHeaders = new HashMap<String, Object>();
        Enumeration<String> properties = message.getPropertyNames();

        String propertyName = null;
        while (properties.hasMoreElements()) {
            propertyName = properties.nextElement();
            requestHeaders.put(propertyName, message.getObjectProperty(propertyName));
        }

        byte[] messageBytes = new byte[(int) (((BytesMessage) message).getBodyLength())];
        ((BytesMessage) message).readBytes(messageBytes);
        Markup.MarkupRequest markupRequest = Markup.MarkupRequest.parseFrom(messageBytes);
        Markup.MarkupResponse.Builder markupResponseBuilder = initializeResponse(markupRequest);
        markupResponseBuilder.setRequestTimestamp(message.getJMSTimestamp());

        log.debug("Processing markup request. Media Index = {}. Media ID = {} (type = {}). Request ID = {}.",
                markupRequest.getMediaIndex(), markupRequest.getMediaId(), markupRequest.getMediaType(),
                markupRequest.getRequestId());

        try {
            if (!new File(URI.create(markupRequest.getDestinationUri())).canWrite()) {
                throw new Exception();
            }
        } catch (Exception exception) {
            markupResponseBuilder.setHasError(true);
            markupResponseBuilder.setErrorMessage(
                    String.format("The target URI '%s' is not writable.", markupRequest.getDestinationUri()));
        }

        try {
            if (!new File(URI.create(markupRequest.getSourceUri())).canRead()) {
                throw new Exception();
            }
        } catch (Exception exception) {
            markupResponseBuilder.setHasError(true);
            markupResponseBuilder.setErrorMessage(
                    String.format("The source URI '%s' is not readable.", markupRequest.getSourceUri()));
        }

        if (!markupResponseBuilder.getHasError()) {
            if (markupRequest.getMapEntriesCount() == 0) {
                try {
                    FileUtils.copyFile(new File(URI.create(markupRequest.getSourceUri())),
                            new File(URI.create(markupRequest.getDestinationUri())));
                    markupResponseBuilder.setOutputFileUri(markupRequest.getDestinationUri());
                } catch (Exception exception) {
                    log.error("Failed to mark up the file '{}' because of an exception.",
                            markupRequest.getSourceUri(), exception);
                    finishWithError(markupResponseBuilder, exception);
                }
            } else if (markupRequest.getMediaType() == Markup.MediaType.IMAGE) {
                try {
                    if (markupImage(markupRequest)) {
                        markupResponseBuilder.setOutputFileUri(markupRequest.getDestinationUri());
                    } else {
                        markupResponseBuilder.setOutputFileUri(markupRequest.getSourceUri());
                    }
                } catch (Exception exception) {
                    log.error("Failed to mark up the image '{}' because of an exception.",
                            markupRequest.getSourceUri(), exception);
                    finishWithError(markupResponseBuilder, exception);
                }
            } else {
                try {
                    if (markupVideo(markupRequest)) {
                        markupResponseBuilder.setOutputFileUri(markupRequest.getDestinationUri());
                    } else {
                        markupResponseBuilder.setOutputFileUri(markupRequest.getDestinationUri());
                    }
                } catch (Exception exception) {
                    log.error("Failed to mark up the video '{}' because of an exception.",
                            markupRequest.getSourceUri(), exception);
                    finishWithError(markupResponseBuilder, exception);
                }
            }
        }

        stopwatch.stop();
        markupResponseBuilder.setTimeProcessing(stopwatch.elapsed(TimeUnit.MILLISECONDS));
        final Markup.MarkupResponse markupResponse = markupResponseBuilder.build();

        log.info("Returning response for Media {}. Error: {}.", markupResponse.getMediaId(),
                markupResponse.getHasError());
        markupResponseTemplate.setSessionTransacted(true);
        markupResponseTemplate.setDefaultDestination(message.getJMSReplyTo());
        markupResponseTemplate.send(new MessageCreator() {
            public Message createMessage(Session session) throws JMSException {
                BytesMessage bytesMessage = session.createBytesMessage();
                bytesMessage.writeBytes(markupResponse.toByteArray());
                for (Map.Entry<String, Object> entry : requestHeaders.entrySet()) {
                    bytesMessage.setObjectProperty(entry.getKey(), entry.getValue());
                }
                return bytesMessage;
            }
        });

    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}

From source file:org.mule.transport.jms.JmsMessageUtils.java

public static Message copyJMSProperties(Message from, Message to, JmsConnector connector) throws JMSException {
    if (connector.supportsProperty(JmsConstants.JMS_CORRELATION_ID)) {
        to.setJMSCorrelationID(from.getJMSCorrelationID());
    }/*from  w  ww .j ava 2s  . c o  m*/
    if (connector.supportsProperty(JmsConstants.JMS_DELIVERY_MODE)) {
        to.setJMSDeliveryMode(from.getJMSDeliveryMode());
    }
    if (connector.supportsProperty(JmsConstants.JMS_DESTINATION)) {
        to.setJMSDestination(from.getJMSDestination());
    }
    if (connector.supportsProperty(JmsConstants.JMS_EXPIRATION)) {
        to.setJMSExpiration(from.getJMSExpiration());
    }
    if (connector.supportsProperty(JmsConstants.JMS_MESSAGE_ID)) {
        to.setJMSMessageID(from.getJMSMessageID());
    }
    if (connector.supportsProperty(JmsConstants.JMS_PRIORITY)) {
        to.setJMSPriority(from.getJMSPriority());
    }
    if (connector.supportsProperty(JmsConstants.JMS_REDELIVERED)) {
        to.setJMSRedelivered(from.getJMSRedelivered());
    }
    if (connector.supportsProperty(JmsConstants.JMS_REPLY_TO)) {
        to.setJMSReplyTo(from.getJMSReplyTo());
    }
    if (connector.supportsProperty(JmsConstants.JMS_TIMESTAMP)) {
        to.setJMSTimestamp(from.getJMSTimestamp());
    }
    if (connector.supportsProperty(JmsConstants.JMS_TYPE)) {
        to.setJMSType(from.getJMSType());
    }
    return to;
}

From source file:org.springframework.flex.messaging.jms.FlexMessageConverter.java

/**
 * /*from   w  w  w .  ja  va2  s  . co m*/
 * {@inheritDoc}
 */
public Object fromMessage(Message message) throws JMSException, MessageConversionException {
    Object messageBody = this.targetConverter.fromMessage(message);
    AsyncMessage flexMessage = new AsyncMessage();
    flexMessage.setBody(messageBody);
    flexMessage.setMessageId(message.getJMSMessageID());
    flexMessage.setClientId(message.getObjectProperty(FLEX_CLIENT_ID));
    flexMessage.setTimestamp(message.getJMSTimestamp());
    Object timeToLive = message.getObjectProperty(FLEX_TIME_TO_LIVE);
    if (timeToLive != null && long.class.isAssignableFrom(timeToLive.getClass())) {
        flexMessage.setTimeToLive(Long.parseLong(timeToLive.toString()));
    }
    Enumeration<?> propertyNames = message.getPropertyNames();
    while (propertyNames.hasMoreElements()) {
        String name = (String) propertyNames.nextElement();
        if (!name.startsWith(HEADER_PREFIX)) {
            flexMessage.setHeader(name, message.getObjectProperty(name));
        }
    }
    return flexMessage;
}