Example usage for javax.jms ObjectMessage clearProperties

List of usage examples for javax.jms ObjectMessage clearProperties

Introduction

In this page you can find the example usage for javax.jms ObjectMessage clearProperties.

Prototype


void clearProperties() throws JMSException;

Source Link

Document

Clears a message's properties.

Usage

From source file:org.grouter.common.jms.QueueSenderDestination.java

/**
 * Helper method that simply puts key value pairs into the JMS header.
 *
 * @param message a serializable object instance
 * @param headerProperties properties to store in header for JMS message
 *
 * @return ObjectMessage an object message
 *//*from w ww.jav a  2 s .  c om*/
private ObjectMessage createMessage(Serializable message, HashMap<String, String> headerProperties) {
    ObjectMessage msg = null;
    try {
        msg = this.queueSession.createObjectMessage(message);
        msg.clearProperties();
        if (headerProperties != null) {
            for (String key : headerProperties.keySet()) {
                String value = headerProperties.get(key);
                msg.setStringProperty(key, value);
            }
        }
    } catch (JMSException e) {
        logger.warn("Failed setting header for message.", e);
    }
    return msg;
}

From source file:org.grouter.common.jms.TopicSenderDestination.java

/**
 * <b>See documentation in {@link org.grouter.common.jms.AbstractSenderDestination#sendMessage(java.io.Serializable,java.util.HashMap)}.</b><br>
 * <br>/*  w  w  w.  java  2s  .c  om*/
 *
 * @param message a serializable object instance
 * @param headerProperties properties to store in header for JMS message
 *
 * @return ObjectMessage an object message
 */
private ObjectMessage createMessage(Serializable message, HashMap<String, String> headerProperties) {
    ObjectMessage msg = null;
    try {
        msg = topicSession.createObjectMessage(message);
        msg.clearProperties();
        if (headerProperties != null) {
            for (String key : headerProperties.keySet()) {
                String value = headerProperties.get(key);
                msg.setStringProperty(key, value);
            }
        }
    } catch (JMSException e) {
        logger.warn("Failed setting header for message.", e);
    }
    return msg;
}