List of usage examples for javax.jms Message getDoubleProperty
double getDoubleProperty(String name) throws JMSException;
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 www .j av a 2s . com*/ * @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.synapse.transport.jms.JMSUtils.java
/** * Extract transport level headers for JMS from the given message into a Map * * @param message the JMS message/*from w ww . j a va 2s. c o m*/ * @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.wso2.carbon.inbound.endpoint.protocol.jms.JMSUtils.java
/** * Extract transport level headers from JMS message into a Map * @param message JMS message// w w w . j ava2 s .c o m * @param msgContext axis2 message context * @return a Map of the transport headers */ public static Map<String, Object> getTransportHeaders(Message message, MessageContext msgContext) { // create a Map to hold transport headers Map<String, Object> map = new HashMap<>(); try { Enumeration<?> propertyNamesEnm = message.getPropertyNames(); while (propertyNamesEnm.hasMoreElements()) { String headerName = (String) propertyNamesEnm.nextElement(); Object headerValue = message.getObjectProperty(headerName); if (headerValue instanceof String) { if (isHyphenReplaceMode(msgContext)) { map.put(inverseTransformHyphenatedString(headerName), message.getStringProperty(headerName)); } else { map.put(headerName, message.getStringProperty(headerName)); } } else if (headerValue instanceof Integer) { map.put(headerName, message.getIntProperty(headerName)); } else if (headerValue instanceof Boolean) { map.put(headerName, message.getBooleanProperty(headerName)); } else if (headerValue instanceof Long) { map.put(headerName, message.getLongProperty(headerName)); } else if (headerValue instanceof Double) { map.put(headerName, message.getDoubleProperty(headerName)); } else if (headerValue instanceof Float) { map.put(headerName, message.getFloatProperty(headerName)); } else { map.put(headerName, headerValue); } } } catch (JMSException e) { log.error("Error while reading the Transport Headers from JMS Message", e); } return map; }