Example usage for javax.jms Message getFloatProperty

List of usage examples for javax.jms Message getFloatProperty

Introduction

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

Prototype


float getFloatProperty(String name) throws JMSException;

Source Link

Document

Returns the value of the float property with the specified name.

Usage

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//  w  ww .  j av a 2s.  co m
 * @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  w w. ja v  a  2  s.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.wso2.carbon.inbound.endpoint.protocol.jms.JMSUtils.java

/**
 * Extract transport level headers from JMS message into a Map
 * @param message JMS message/*from w w  w . j av a 2s.c  om*/
 * @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;
}