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); } }
public static void setDataTable(Message message, Hashtable dataTable) throws JMSException { if (dataTable == null) { return; } message.setObjectProperty(MessagePropertyNames.DATA_TABLE, dataTable); }
public static void setAttachments(Message message, Hashtable attachmentTable) throws JMSException { if (attachmentTable == null) { return; } message.setObjectProperty(MessagePropertyNames.ATTACHMENT_TABLE, attachmentTable); }
public static void setBytesData(Message message, byte[] data) throws JMSException { if (data == null) { return; } if (message instanceof BytesMessage) { BytesMessage bytesMessage = (BytesMessage) message; bytesMessage.clearBody(); bytesMessage.writeBytes(data); } else { message.setObjectProperty(MessagePropertyNames.BYTES_DATA, data); } }
public static void addDataEntry(Message message, Object name, Object value) throws JMSException { Hashtable dataTable = null; if (!message.propertyExists(MessagePropertyNames.DATA_TABLE)) { dataTable = new Hashtable(); } else { dataTable = (Hashtable) message.getObjectProperty(MessagePropertyNames.DATA_TABLE); } dataTable.put(name, value); if (!message.propertyExists(MessagePropertyNames.DATA_TABLE)) { message.setObjectProperty(MessagePropertyNames.DATA_TABLE, dataTable); } }
public static void addAttachment(Message message, Object name, Object value) throws JMSException { Hashtable headerTable = null; if (!message.propertyExists(MessagePropertyNames.ATTACHMENT_TABLE)) { headerTable = new Hashtable(); } else { headerTable = (Hashtable) message.getObjectProperty(MessagePropertyNames.ATTACHMENT_TABLE); } headerTable.put(name, value); if (!message.propertyExists(MessagePropertyNames.ATTACHMENT_TABLE)) { message.setObjectProperty(MessagePropertyNames.ATTACHMENT_TABLE, headerTable); } }