Example usage for javax.jms Message setByteProperty

List of usage examples for javax.jms Message setByteProperty

Introduction

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

Prototype


void setByteProperty(String name, byte value) throws JMSException;

Source Link

Document

Sets a byte property value with the specified name into the message.

Usage

From source file:org.sdnmq.jms.PacketHandler.java

/**
 * Adds properties to a message according to IEEE802.1q frame information.
 * //from  www  . j  av a2  s . c o m
 * @param ieee8021q the IEEE802.q frame
 * @param json the JSON object to which the information will be added
 */
private void ieee8021qToProperties(IEEE8021Q ieee8021q, Message msg) {
    try {
        msg.setShortProperty(MessageFilterAttributes.Keys.DL_VLAN.toFilterName(), (short) ieee8021q.getVid());
    } catch (JMSException e) {
        log.error(e.getMessage());
    }

    try {
        msg.setByteProperty(MessageFilterAttributes.Keys.DL_VLAN_PR.toFilterName(), ieee8021q.getPcp());
    } catch (JMSException e) {
        log.error(e.getMessage());
    }
}

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 {/* w w w  .  j ava 2 s. co  m*/
        message.setObjectProperty(propertyName, propertyValue);
    }
}

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 {//www .j  a va 2  s  . c  o m
            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   w w w. j av  a  2s  .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.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());
        }// w w w  .j  a v a  2 s  . co  m
    }
}