/** * Set the specified properties in the message. * * @param properties * @throws JMSException */ protected void setMessageProperties(Message message, Map<String, ?> properties) throws JMSException { if (properties != null) { for (Map.Entry<String, ?> entry : properties.entrySet()) { Object value = entry.getValue(); if (value instanceof String) { message.setStringProperty(entry.getKey(), (String) value); } else if (value instanceof Integer) { message.setIntProperty(entry.getKey(), (Integer) value); } else if (value instanceof Boolean) { message.setBooleanProperty(entry.getKey(), (Boolean) value); } else if (value instanceof Byte) { message.setByteProperty(entry.getKey(), (Byte) value); } else if (value instanceof Double) { message.setDoubleProperty(entry.getKey(), (Double) value); } else if (value instanceof Float) { message.setFloatProperty(entry.getKey(), (Float) value); } else if (value instanceof Long) { message.setLongProperty(entry.getKey(), (Long) value); } else if (value instanceof Short) { message.setShortProperty(entry.getKey(), (Short) value); } else { message.setObjectProperty(entry.getKey(), value); } } } }
public static void setProperty(String name, Object value, Message jmsMessage) throws JMSException { if (jmsMessage == null || name == null) { return; } if (value instanceof Boolean) { jmsMessage.setBooleanProperty(name, ((Boolean) value).booleanValue()); } else if (value instanceof Byte) { jmsMessage.setByteProperty(name, ((Byte) value).byteValue()); } else if (value instanceof Double) { jmsMessage.setDoubleProperty(name, ((Double) value).doubleValue()); } else if (value instanceof Float) { jmsMessage.setFloatProperty(name, ((Float) value).floatValue()); } else if (value instanceof Integer) { jmsMessage.setIntProperty(name, ((Integer) value).intValue()); } else if (value instanceof Long) { jmsMessage.setLongProperty(name, ((Long) value).longValue()); } else if (value instanceof Short) { jmsMessage.setShortProperty(name, ((Short) value).shortValue()); } else if (value instanceof String) { jmsMessage.setStringProperty(name, (String) value); } else { jmsMessage.setObjectProperty(name, value); } }
Message createReportResponseMessage(String msg) throws JMSException { Message message = _session.createTextMessage(msg); // Shove some more field table type in the message just to see if the other end can handle it. message.setBooleanProperty("BOOLEAN", true); message.setByteProperty("BYTE", (byte) 5); message.setDoubleProperty("DOUBLE", Math.PI); message.setFloatProperty("FLOAT", 1.0f); message.setIntProperty("INT", 1); message.setShortProperty("SHORT", (short) 1); message.setLongProperty("LONG", (long) 1827361278); message.setStringProperty("STRING", "hello"); return message; }
public static void setEventGenerationDate(Message message, long date) throws JMSException { message.setLongProperty(MessagePropertyNames.EVENT_GENERATION_DATE, date); }
public static void setTotalTime(Message message, long time) throws JMSException { message.setLongProperty(MessagePropertyNames.TOTAL_TIME, time); }
public static void setOutTime(Message message, long time) throws JMSException { message.setLongProperty(MessagePropertyNames.OUT_TIME, time); }
public static void setInTime(Message message, long intime) throws JMSException { message.setLongProperty(MessagePropertyNames.IN_TIME, intime); }