List of usage examples for javax.jms Message setFloatProperty
void setFloatProperty(String name, float value) throws JMSException;
From source file:cherry.foundation.async.PropertyMessagePostProcessor.java
@Override public Message postProcessMessage(Message message) throws JMSException { for (Map.Entry<String, Object> entry : properties.entrySet()) { String name = entry.getKey(); Object v = entry.getValue(); if (v instanceof String) { message.setStringProperty(name, (String) v); } else if (v instanceof Integer) { message.setIntProperty(name, ((Integer) v).intValue()); } else if (v instanceof Long) { message.setLongProperty(name, ((Long) v).longValue()); } else if (v instanceof Short) { message.setShortProperty(name, ((Short) v).shortValue()); } else if (v instanceof Byte) { message.setByteProperty(name, ((Byte) v).byteValue()); } else if (v instanceof Boolean) { message.setBooleanProperty(name, ((Boolean) v).booleanValue()); } else if (v instanceof Double) { message.setDoubleProperty(name, ((Double) v).doubleValue()); } else if (v instanceof Float) { message.setFloatProperty(name, ((Float) v).floatValue()); } else {// w ww .j a v a2 s. c om message.setObjectProperty(name, v); } } return message; }
From source file:nl.nn.adapterframework.jms.JmsSender.java
/** * sets the JMS message properties as descriped in the msgProperties arraylist * @param msg//from ww w. ja v a 2 s.c o m * @param msgProperties * @throws JMSException */ private void setProperties(Message msg, ParameterValueList msgProperties) throws JMSException { for (int i = 0; i < msgProperties.size(); i++) { ParameterValue property = msgProperties.getParameterValue(i); String type = property.getDefinition().getType(); String name = property.getDefinition().getName(); if (!isSoap() || !name.equals(getSoapHeaderParam())) { if (log.isDebugEnabled()) { log.debug(getLogPrefix() + "setting [" + type + "] property from param [" + name + "] to value [" + property.getValue() + "]"); } if ("boolean".equalsIgnoreCase(type)) msg.setBooleanProperty(name, property.asBooleanValue(false)); else if ("byte".equalsIgnoreCase(type)) msg.setByteProperty(name, property.asByteValue((byte) 0)); else if ("double".equalsIgnoreCase(type)) msg.setDoubleProperty(name, property.asDoubleValue(0)); else if ("float".equalsIgnoreCase(type)) msg.setFloatProperty(name, property.asFloatValue(0)); else if ("int".equalsIgnoreCase(type)) msg.setIntProperty(name, property.asIntegerValue(0)); else if ("long".equalsIgnoreCase(type)) msg.setLongProperty(name, property.asLongValue(0L)); else if ("short".equalsIgnoreCase(type)) msg.setShortProperty(name, property.asShortValue((short) 0)); else if ("string".equalsIgnoreCase(type)) msg.setStringProperty(name, property.asStringValue("")); else // if ("object".equalsIgnoreCase(type)) msg.setObjectProperty(name, property.getValue()); } } }
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/*from w ww. jav 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) { 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.apache.qpid.disttest.client.MessageProvider.java
protected void setCustomProperty(Message message, String propertyName, Object propertyValue) throws JMSException { if (propertyValue instanceof Integer) { message.setIntProperty(propertyName, ((Integer) propertyValue).intValue()); } else if (propertyValue instanceof Long) { message.setLongProperty(propertyName, ((Long) propertyValue).longValue()); } else if (propertyValue instanceof Boolean) { message.setBooleanProperty(propertyName, ((Boolean) propertyValue).booleanValue()); } else if (propertyValue instanceof Byte) { message.setByteProperty(propertyName, ((Byte) propertyValue).byteValue()); } else if (propertyValue instanceof Double) { message.setDoubleProperty(propertyName, ((Double) propertyValue).doubleValue()); } else if (propertyValue instanceof Float) { message.setFloatProperty(propertyName, ((Float) propertyValue).floatValue()); } else if (propertyValue instanceof Short) { message.setShortProperty(propertyName, ((Short) propertyValue).shortValue()); } else if (propertyValue instanceof String) { message.setStringProperty(propertyName, (String) propertyValue); } else {/*from w ww .ja v a 2 s . c o m*/ message.setObjectProperty(propertyName, propertyValue); } }
From source file:org.apache.synapse.message.store.impl.jms.JmsProducer.java
private void setJmsMessageProperties(Message message, MessageContext synCtx) { Set<String> properties = synCtx.getPropertyKeySet(); for (String prop : properties) { if (prop.startsWith(JMS_MSG_P)) { Object value = synCtx.getProperty(prop); String key = prop.substring(JMS_MSG_P.length()); try { if (value instanceof String) { message.setStringProperty(key, (String) value); } else if (value instanceof Long) { message.setLongProperty(key, (Long) value); } else if (value instanceof Integer) { message.setIntProperty(key, (Integer) value); } else if (value instanceof Boolean) { message.setBooleanProperty(key, (Boolean) value); } else if (value instanceof Double) { message.setDoubleProperty(key, (Double) value); } else if (value instanceof Float) { message.setFloatProperty(key, (Float) value); } else if (value instanceof Short) { message.setShortProperty(key, (Short) value); }//from w ww.ja va 2 s. com } catch (JMSException e) { if (logger.isDebugEnabled()) { logger.debug("Could not save Message property: " + e.getLocalizedMessage()); } } } } }
From source file:org.apache.synapse.message.store.impl.jms.JmsProducer.java
private void setTransportHeaders(Message message, MessageContext synCtx) { //Set transport headers to the message Map<?, ?> headerMap = (Map<?, ?>) ((Axis2MessageContext) synCtx).getAxis2MessageContext() .getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS); if (headerMap != null) { for (Object headerName : headerMap.keySet()) { String name = (String) headerName; Object value = headerMap.get(name); try { 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 ww w .java 2s.c o m*/ } catch (JMSException ex) { if (logger.isDebugEnabled()) { logger.debug("Could not save Message property: " + ex.getLocalizedMessage()); } } } } }
From source file:org.apache.synapse.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 . ja va 2 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; } Iterator iter = headerMap.keySet().iterator(); while (iter.hasNext()) { String name = (String) iter.next(); 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).intValue()); } 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).booleanValue()); } else if (value instanceof Integer) { message.setIntProperty(name, ((Integer) value).intValue()); } else if (value instanceof Long) { message.setLongProperty(name, ((Long) value).longValue()); } else if (value instanceof Double) { message.setDoubleProperty(name, ((Double) value).doubleValue()); } else if (value instanceof Float) { message.setFloatProperty(name, ((Float) value).floatValue()); } } } }
From source file:org.openanzo.combus.realtime.RealtimeUpdatePublisher.java
private void setMessageProperties(Message message, Map<String, Object> properties) throws JMSException { // How can we do this more efficiently? for (Map.Entry<String, Object> entry : properties.entrySet()) { String name = entry.getKey(); Object value = entry.getValue(); if (value instanceof String) { message.setStringProperty(name, (String) value); } else if (value instanceof Integer) { message.setIntProperty(name, ((Integer) value).intValue()); } else if (value instanceof Long) { message.setLongProperty(name, ((Long) value).longValue()); } else if (value instanceof Float) { message.setFloatProperty(name, ((Float) value).floatValue()); } else if (value instanceof Double) { message.setDoubleProperty(name, ((Double) value).doubleValue()); } else if (value instanceof Short) { message.setShortProperty(name, ((Short) value).shortValue()); } else if (value instanceof Byte) { message.setByteProperty(name, ((Byte) value).byteValue()); } else if (value instanceof Boolean) { message.setBooleanProperty(name, ((Boolean) value).booleanValue()); }/*from w w w . j ava2 s. co m*/ } }
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 w ww. j a v a 2 s .c o m */ 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 w w. j av a 2 s. c om 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; }