List of usage examples for javax.jms Message setJMSCorrelationID
void setJMSCorrelationID(String correlationID) throws JMSException;
From source file:org.openengsb.ports.jms.JMSIncomingPort.java
public void start() { simpleMessageListenerContainer = createListenerContainer(receive, new MessageListener() { @Override/*from ww w.ja va 2 s.c o m*/ public void onMessage(Message message) { LOGGER.trace("JMS-message recieved. Checking if the type is supported"); if (!(message instanceof TextMessage)) { LOGGER.debug("Received JMS-message is not type of text message."); return; } LOGGER.trace("Received a text message and start parsing"); TextMessage textMessage = (TextMessage) message; String textContent = extractTextFromMessage(textMessage); HashMap<String, Object> metadata = new HashMap<String, Object>(); String result = null; try { LOGGER.debug("starting filterchain for incoming message"); result = (String) getFilterChainToUse().filter(textContent, metadata); } catch (Exception e) { LOGGER.error("an error occured when processing the filterchain", e); result = ExceptionUtils.getStackTrace(e); } Destination replyQueue; final String correlationID; try { if (message.getJMSCorrelationID() == null) { correlationID = message.getJMSMessageID(); } else { correlationID = message.getJMSCorrelationID(); } replyQueue = message.getJMSReplyTo(); } catch (JMSException e) { LOGGER.warn("error when getting destination queue or correlationid from client message: {}", e); return; } if (replyQueue == null) { LOGGER.warn("no replyTo destination specifyed could not send response"); return; } new JmsTemplate(connectionFactory).convertAndSend(replyQueue, result, new MessagePostProcessor() { @Override public Message postProcessMessage(Message message) throws JMSException { message.setJMSCorrelationID(correlationID); return message; } }); } private String extractTextFromMessage(TextMessage textMessage) { try { return textMessage.getText(); } catch (JMSException e) { throw new IllegalStateException("Couldn't extract text from jms message", e); } } }); simpleMessageListenerContainer.start(); }
From source file:org.oxymores.chronix.engine.RunnerAgent.java
@Override public void onMessage(Message msg) { log.info("Run request received"); ObjectMessage omsg = (ObjectMessage) msg; RunDescription rd;/*from ww w . j a v a2 s. c o m*/ RunResult res = null; try { Object o = omsg.getObject(); if (!(o instanceof RunDescription)) { log.warn("An object was received on the runner queue but was not a RunDescription! Ignored."); jmsCommit(); return; } rd = (RunDescription) o; } catch (JMSException e) { log.error( "An error occurred during RunDescription reception. Message will stay in queue and will be analysed later", e); jmsRollback(); return; } if (!rd.getHelperExecRequest()) { log.info(String.format("Running command %s", rd.getCommand())); } else { log.debug(String.format("Running helper internal command %s", rd.getCommand())); } // Log file (only if true run) String logFilePath = null; String logFileName = null; Date start = new Date(); if (!rd.getHelperExecRequest()) { SimpleDateFormat myFormatDir = new SimpleDateFormat("yyyyMMdd"); SimpleDateFormat myFormatFile = new SimpleDateFormat("yyyyMMddhhmmssSSS"); String dd = myFormatDir.format(start); String logFileDateDir = FilenameUtils.concat(this.logDbPath, dd); if (!(new File(logFileDateDir)).exists() && !(new File(logFileDateDir)).mkdir()) { log.fatal("Could not create log directory, failing engine"); this.broker.stop(); jmsRollback(); return; } logFileName = String.format("%s_%s_%s_%s.log", myFormatFile.format(start), rd.getPlaceName().replace(" ", "-"), rd.getActiveSourceName().replace(" ", "-"), rd.getId1()); logFilePath = FilenameUtils.concat(logFileDateDir, logFileName); } // Run the command according to its method if (rd.getMethod().equals(Constants.JD_METHOD_SHELL)) { res = RunnerShell.run(rd, logFilePath, !rd.getHelperExecRequest(), rd.getShouldSendLogFile()); } else { res = new RunResult(); res.returnCode = -1; res.logStart = String.format("An unimplemented exec method (%s) was called!", rd.getMethod()); log.error(String.format("An unimplemented exec method (%s) was called! Job will be failed.", rd.getMethod())); } res.start = start; res.end = new Date(); res.logFileName = logFileName; res.logPath = logFilePath; // Copy the engine ids - that way it will be able to identify the launch // Part of the ids are in the JMS correlation id too res.id1 = rd.getId1(); res.id2 = rd.getId2(); res.outOfPlan = rd.getOutOfPlan(); // Send the result! Message response; if (!rd.getHelperExecRequest()) { InputStream is = null; try { response = jmsSession.createObjectMessage(res); response.setJMSCorrelationID(msg.getJMSCorrelationID()); jmsProducer.send(msg.getJMSReplyTo(), response); if (res.logSizeBytes <= 500000) { response = jmsSession.createBytesMessage(); byte[] bytes = new byte[(int) res.logSizeBytes]; is = new FileInputStream(res.logPath); is.read(bytes); IOUtils.closeQuietly(is); ((BytesMessage) response).writeBytes(bytes); response.setJMSCorrelationID(msg.getJMSCorrelationID()); response.setStringProperty("FileName", logFileName); jmsProducer.send(msg.getJMSReplyTo(), response); } else { log.warn( "A log file was too big and will not be sent. Only the full log file will be missing - the launch will still appear in the console."); } } catch (Exception e1) { log.error( "The runner was not able to send the result of an execution to the engine. This may corrupt plan execution!", e1); IOUtils.closeQuietly(is); } } else { try { response = jmsSession.createTextMessage(res.logStart); response.setJMSCorrelationID(msg.getJMSCorrelationID()); jmsProducer.send(msg.getJMSReplyTo(), response); } catch (JMSException e1) { log.error( "The runner was not able to send the result of a parameter resolution to the engine. This may corrupt plan execution!", e1); } } jmsCommit(); }
From source file:org.springframework.integration.jms.DefaultJmsHeaderMapper.java
public void fromHeaders(MessageHeaders headers, javax.jms.Message jmsMessage) { try {/*from w w w.j a v a2s .c o m*/ Object jmsCorrelationId = headers.get(JmsHeaders.CORRELATION_ID); if (jmsCorrelationId instanceof Number) { jmsCorrelationId = ((Number) jmsCorrelationId).toString(); } if (jmsCorrelationId instanceof String) { try { jmsMessage.setJMSCorrelationID((String) jmsCorrelationId); } catch (Exception e) { logger.info("failed to set JMSCorrelationID, skipping", e); } } Object jmsReplyTo = headers.get(JmsHeaders.REPLY_TO); if (jmsReplyTo instanceof Destination) { try { jmsMessage.setJMSReplyTo((Destination) jmsReplyTo); } catch (Exception e) { logger.info("failed to set JMSReplyTo, skipping", e); } } Object jmsType = headers.get(JmsHeaders.TYPE); if (jmsType instanceof String) { try { jmsMessage.setJMSType((String) jmsType); } catch (Exception e) { logger.info("failed to set JMSType, skipping", e); } } Set<String> headerNames = headers.keySet(); for (String headerName : headerNames) { if (StringUtils.hasText(headerName) && !headerName.startsWith(JmsHeaders.PREFIX)) { Object value = headers.get(headerName); if (value != null && SUPPORTED_PROPERTY_TYPES.contains(value.getClass())) { try { String propertyName = this.fromHeaderName(headerName); jmsMessage.setObjectProperty(propertyName, value); } catch (Exception e) { if (headerName.startsWith("JMSX")) { if (logger.isTraceEnabled()) { logger.trace( "skipping reserved header, it cannot be set by client: " + headerName); } } else if (logger.isWarnEnabled()) { logger.warn("failed to map Message header '" + headerName + "' to JMS property", e); } } } } } } catch (Exception e) { if (logger.isWarnEnabled()) { logger.warn("error occurred while mapping from MessageHeaders to JMS properties", e); } } }
From source file:org.springframework.jms.listener.adapter.AbstractAdaptableMessageListener.java
/** * Post-process the given response message before it will be sent. * <p>The default implementation sets the response's correlation id * to the request message's correlation id, if any; otherwise to the * request message id./*from w ww. j a va2 s . c o m*/ * @param request the original incoming JMS message * @param response the outgoing JMS message about to be sent * @throws JMSException if thrown by JMS API methods * @see javax.jms.Message#setJMSCorrelationID */ protected void postProcessResponse(Message request, Message response) throws JMSException { String correlation = request.getJMSCorrelationID(); if (correlation == null) { correlation = request.getJMSMessageID(); } response.setJMSCorrelationID(correlation); }
From source file:org.springframework.jms.support.converter.SimpleJmsHeaderMapper.java
@Override public void fromHeaders(MessageHeaders headers, javax.jms.Message jmsMessage) { try {//from ww w .jav a 2 s .c o m Object jmsCorrelationId = headers.get(JmsHeaders.CORRELATION_ID); if (jmsCorrelationId instanceof Number) { jmsCorrelationId = jmsCorrelationId.toString(); } if (jmsCorrelationId instanceof String) { try { jmsMessage.setJMSCorrelationID((String) jmsCorrelationId); } catch (Exception e) { logger.info("failed to set JMSCorrelationID, skipping", e); } } Object jmsReplyTo = headers.get(JmsHeaders.REPLY_TO); if (jmsReplyTo instanceof Destination) { try { jmsMessage.setJMSReplyTo((Destination) jmsReplyTo); } catch (Exception e) { logger.info("failed to set JMSReplyTo, skipping", e); } } Object jmsType = headers.get(JmsHeaders.TYPE); if (jmsType instanceof String) { try { jmsMessage.setJMSType((String) jmsType); } catch (Exception e) { logger.info("failed to set JMSType, skipping", e); } } Set<String> headerNames = headers.keySet(); for (String headerName : headerNames) { if (StringUtils.hasText(headerName) && !headerName.startsWith(JmsHeaders.PREFIX)) { Object value = headers.get(headerName); if (value != null && SUPPORTED_PROPERTY_TYPES.contains(value.getClass())) { try { String propertyName = this.fromHeaderName(headerName); jmsMessage.setObjectProperty(propertyName, value); } catch (Exception e) { if (headerName.startsWith("JMSX")) { if (logger.isTraceEnabled()) { logger.trace( "skipping reserved header, it cannot be set by client: " + headerName); } } else if (logger.isWarnEnabled()) { logger.warn("failed to map Message header '" + headerName + "' to JMS property", e); } } } } } } catch (Exception e) { if (logger.isWarnEnabled()) { logger.warn("error occurred while mapping from MessageHeaders to JMS properties", e); } } }
From source file:org.springframework.jms.support.SimpleJmsHeaderMapper.java
@Override public void fromHeaders(MessageHeaders headers, javax.jms.Message jmsMessage) { try {//from w ww . jav a2 s .co m Object jmsCorrelationId = headers.get(JmsHeaders.CORRELATION_ID); if (jmsCorrelationId instanceof Number) { jmsCorrelationId = jmsCorrelationId.toString(); } if (jmsCorrelationId instanceof String) { try { jmsMessage.setJMSCorrelationID((String) jmsCorrelationId); } catch (Exception e) { logger.info("failed to set JMSCorrelationID, skipping", e); } } Object jmsReplyTo = headers.get(JmsHeaders.REPLY_TO); if (jmsReplyTo instanceof Destination) { try { jmsMessage.setJMSReplyTo((Destination) jmsReplyTo); } catch (Exception e) { logger.info("failed to set JMSReplyTo, skipping", e); } } Object jmsType = headers.get(JmsHeaders.TYPE); if (jmsType instanceof String) { try { jmsMessage.setJMSType((String) jmsType); } catch (Exception e) { logger.info("failed to set JMSType, skipping", e); } } Set<String> headerNames = headers.keySet(); for (String headerName : headerNames) { if (StringUtils.hasText(headerName) && !headerName.startsWith(JmsHeaders.PREFIX)) { Object value = headers.get(headerName); if (value != null && SUPPORTED_PROPERTY_TYPES.contains(value.getClass())) { try { String propertyName = this.fromHeaderName(headerName); jmsMessage.setObjectProperty(propertyName, value); } catch (Exception e) { if (headerName.startsWith("JMSX")) { if (logger.isTraceEnabled()) { logger.trace( "skipping reserved header, it cannot be set by client: " + headerName); } } else if (logger.isWarnEnabled()) { logger.warn("failed to map Message header '" + headerName + "' to JMS property", e); } } } } } } catch (Exception ex) { if (logger.isWarnEnabled()) { logger.warn("error occurred while mapping from MessageHeaders to JMS properties", ex); } } }
From source file:org.wso2.carbon.apimgt.jms.listener.utils.JMSUtils.java
/** * Set transport headers from the axis message context, into the JMS message * * @param messageConfiguration the adaptor message context * @param message the JMS Message * @throws JMSException on exception//from ww w. j a v a 2 s.com */ public static void setTransportHeaders(Map<String, String> messageConfiguration, Message message) throws JMSException { if (messageConfiguration == null) { return; } for (String name : messageConfiguration.keySet()) { 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(messageConfiguration.get(JMSConstants.JMS_COORELATION_ID)); } else if (JMSConstants.JMS_DELIVERY_MODE.equals(name)) { String mode = messageConfiguration.get(JMSConstants.JMS_DELIVERY_MODE); try { message.setJMSDeliveryMode(Integer.parseInt(mode)); } catch (NumberFormatException nfe) { log.warn("Invalid delivery mode ignored : " + mode, nfe); } } else if (JMSConstants.JMS_EXPIRATION.equals(name)) { message.setJMSExpiration(Long.parseLong(messageConfiguration.get(JMSConstants.JMS_EXPIRATION))); } else if (JMSConstants.JMS_MESSAGE_ID.equals(name)) { message.setJMSMessageID(messageConfiguration.get(JMSConstants.JMS_MESSAGE_ID)); } else if (JMSConstants.JMS_PRIORITY.equals(name)) { message.setJMSPriority(Integer.parseInt(messageConfiguration.get(JMSConstants.JMS_PRIORITY))); } else if (JMSConstants.JMS_TIMESTAMP.equals(name)) { message.setJMSTimestamp(Long.parseLong(messageConfiguration.get(JMSConstants.JMS_TIMESTAMP))); } else if (JMSConstants.JMS_MESSAGE_TYPE.equals(name)) { message.setJMSType(messageConfiguration.get(JMSConstants.JMS_MESSAGE_TYPE)); } else { //TODO currently only string is supported in messageConfiguration Object value = messageConfiguration.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); } } } }
From source file:org.wso2.carbon.event.output.adapter.jms.internal.util.JMSUtils.java
/** * Set transport headers from the axis message context, into the JMS message * * @param messageConfiguration the adaptor message context * @param message the JMS Message * @throws javax.jms.JMSException on exception *///from w ww . j a v a 2s.c o m public static Message setTransportHeaders(Map<String, String> messageConfiguration, Message message) throws JMSException { if (messageConfiguration == null) { return message; } for (String name : messageConfiguration.keySet()) { 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(messageConfiguration.get(JMSConstants.JMS_COORELATION_ID)); } else if (JMSConstants.JMS_DELIVERY_MODE.equals(name)) { String mode = messageConfiguration.get(JMSConstants.JMS_DELIVERY_MODE); try { message.setJMSDeliveryMode(Integer.parseInt(mode)); } catch (NumberFormatException nfe) { log.warn("Invalid delivery mode ignored : " + mode, nfe); } } else if (JMSConstants.JMS_EXPIRATION.equals(name)) { message.setJMSExpiration(Long.parseLong(messageConfiguration.get(JMSConstants.JMS_EXPIRATION))); } else if (JMSConstants.JMS_MESSAGE_ID.equals(name)) { message.setJMSMessageID(messageConfiguration.get(JMSConstants.JMS_MESSAGE_ID)); } else if (JMSConstants.JMS_PRIORITY.equals(name)) { message.setJMSPriority(Integer.parseInt(messageConfiguration.get(JMSConstants.JMS_PRIORITY))); } else if (JMSConstants.JMS_TIMESTAMP.equals(name)) { message.setJMSTimestamp(Long.parseLong(messageConfiguration.get(JMSConstants.JMS_TIMESTAMP))); } else if (JMSConstants.JMS_MESSAGE_TYPE.equals(name)) { message.setJMSType(messageConfiguration.get(JMSConstants.JMS_MESSAGE_TYPE)); } else { //TODO currently only string is supported in messageConfiguration Object value = messageConfiguration.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); } } } return message; }
From source file:org.wso2.carbon.inbound.endpoint.protocol.jms.JMSReplySender.java
/** * Create a JMS Message from the given MessageContext and using the given * session/*w w w. j a v a 2 s . co 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 synCtx, Session session, String contentTypeProperty) throws JMSException { Message message = null; org.apache.axis2.context.MessageContext msgContext = ((Axis2MessageContext) synCtx) .getAxis2MessageContext(); String msgType = getProperty(msgContext, JMSConstants.JMS_MESSAGE_TYPE); String jmsPayloadType = guessMessageType(msgContext); if (jmsPayloadType == null) { OMOutputFormat format = BaseUtils.getOMOutputFormat(msgContext); MessageFormatter messageFormatter = null; try { messageFormatter = MessageProcessorSelector.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) { log.error("Unsupported encoding " + format.getCharSetEncoding(), ex); throw new JMSException("Unsupported encoding " + format.getCharSetEncoding()); } } try { messageFormatter.writeTo(msgContext, format, out, true); out.close(); } catch (IOException e) { log.error("IO Error while creating BytesMessage", e); throw new JMSException("IO Error while creating BytesMessage"); } 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) { log.error("Error serializing binary content of element : " + BaseConstants.DEFAULT_BINARY_WRAPPER, e); throw new JMSException("Error serializing binary content of element : " + BaseConstants.DEFAULT_BINARY_WRAPPER); } } } } 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()); } else if (JMSConstants.JMS_MAP_MESSAGE.equalsIgnoreCase(jmsPayloadType)) { message = session.createMapMessage(); JMSUtils.convertXMLtoJMSMap( msgContext.getEnvelope().getBody().getFirstChildWithName(JMSConstants.JMS_MAP_QNAME), (MapMessage) message); } // set the JMS correlation ID if specified String correlationId = (String) synCtx.getProperty(JMSConstants.JMS_COORELATION_ID); 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.wso2.carbon.inbound.endpoint.protocol.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//from ww w. ja v a2 s . c om * @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) { if (name.contains("-")) { if (isHyphenReplaceMode(msgContext)) { // we replace message.setStringProperty(transformHyphenatedString(name), (String) value); } else if (isHyphenDeleteMode(msgContext)) { // we skip continue; } else { message.setStringProperty(name, (String) value); } } else { 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); } } } }