Example usage for javax.jms Message setShortProperty

List of usage examples for javax.jms Message setShortProperty

Introduction

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

Prototype


void setShortProperty(String name, short value) throws JMSException;

Source Link

Document

Sets a short 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  w  w  w  .j  a v  a2  s. co 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.sdnmq.jms.PacketHandler.java

/**
 * Adds properties to a message according to TCP datagram header fields.
 * //from  w  ww. j a  v a 2s .c  o  m
 * @param tcp the TCP datagram
 * @param msg the message to which the information will be added
 */
private void tcpToProperties(TCP tcp, Message msg) {
    try {
        msg.setShortProperty(MessageFilterAttributes.Keys.TP_SRC.toFilterName(), tcp.getSourcePort());
    } catch (JMSException e) {
        log.error(e.getMessage());
    }

    try {
        msg.setShortProperty(MessageFilterAttributes.Keys.TP_DST.toFilterName(), tcp.getDestinationPort());
    } catch (JMSException e) {
        log.error(e.getMessage());
    }
}

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

/**
 * Sets message properties according to UDP datagram header fields.
 * /*  ww w  . j av a2 s  .  c o m*/
 * @param udp the UDP datagram
 * @param msg the message to which the information will be added
 */
private void udpToProperties(UDP udp, Message msg) {
    try {
        msg.setShortProperty(MessageFilterAttributes.Keys.TP_SRC.toFilterName(), udp.getSourcePort());
    } catch (JMSException e) {
        log.error(e.getMessage());
    }

    try {
        msg.setShortProperty(MessageFilterAttributes.Keys.TP_DST.toFilterName(), udp.getDestinationPort());
    } catch (JMSException e) {
        log.error(e.getMessage());
    }
}

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 w  w.ja v a  2  s .  c o m
            message.setObjectProperty(name, v);
        }
    }
    return message;
}

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

/**
 * Adds message properties according to Ethernet header fields.
 * //w ww  .j  a v a2 s. co  m
 * @param ethernet the Ethernet frame
 * @param msg the message object to which the information will be added
 */
private void ethernetToProperties(Ethernet ethernet, Message msg) {
    try {
        msg.setStringProperty(MessageFilterAttributes.Keys.DL_SRC.toFilterName(),
                Netutil.macToStr(ethernet.getSourceMACAddress()));
    } catch (JMSException e) {
        log.error(e.getMessage());
    }

    try {
        msg.setStringProperty(MessageFilterAttributes.Keys.DL_DST.toFilterName(),
                Netutil.macToStr(ethernet.getDestinationMACAddress()));
    } catch (JMSException e) {
        log.error(e.getMessage());
    }

    try {
        msg.setShortProperty(MessageFilterAttributes.Keys.DL_TYPE.toFilterName(), ethernet.getEtherType());
    } 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 {/* ww w .  j av a2  s.  c  o  m*/
        message.setObjectProperty(propertyName, propertyValue);
    }
}

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

/**
 * Adds message properties according to IPv4 header fields.
 * //from  w w  w .  ja  v  a  2  s  .co  m
 * @param ipv4 the IPv4 packet
 * @param msg the message whose properties are set
 */
private void ipv4ToProperties(IPv4 ipv4, Message msg) {
    try {
        msg.setStringProperty(MessageFilterAttributes.Keys.NW_SRC.toFilterName(),
                Netutil.ipv4ToStr(ipv4.getSourceAddress()));
        msg.setStringProperty(MessageFilterAttributes.Keys.NW_SRC_BINARY.toFilterName(),
                Netutil.ipv4ToBinaryStr(ipv4.getSourceAddress()));
    } catch (JMSException e) {
        log.error(e.getMessage());
    }

    try {
        msg.setStringProperty(MessageFilterAttributes.Keys.NW_DST.toFilterName(),
                Netutil.ipv4ToStr(ipv4.getDestinationAddress()));
        msg.setStringProperty(MessageFilterAttributes.Keys.NW_DST_BINARY.toFilterName(),
                Netutil.ipv4ToBinaryStr(ipv4.getDestinationAddress()));
    } catch (JMSException e) {
        log.error(e.getMessage());
    }

    try {
        msg.setShortProperty(MessageFilterAttributes.Keys.NW_PROTOCOL.toFilterName(),
                (short) ipv4.getProtocol());
    } catch (JMSException e) {
        log.error(e.getMessage());
    }
}

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   ww  w.j  av  a 2  s .  c  o  m*/
            } catch (JMSException e) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Could not save Message property: " + e.getLocalizedMessage());
                }
            }
        }
    }
}

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  ww. j ava 2 s  .  co m
    }
}

From source file:nl.nn.adapterframework.jms.JmsSender.java

/**
 * sets the JMS message properties as descriped in the msgProperties arraylist
 * @param msg/*  w  ww  .j  a va2  s .  c  om*/
 * @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());
        }
    }
}