List of usage examples for javax.jms Message clearProperties
void clearProperties() throws JMSException;
From source file:com.mirth.connect.connectors.jms.transformers.AbstractJmsTransformer.java
/** * @param src The source data to compress * @return//from www . ja va 2 s . c o 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); } }