@Override public JMSProducer send(Destination destination, byte[] body) { BytesMessage message = context.createBytesMessage(); if (body != null) { try { message.writeBytes(body); } catch (JMSException e) { throw new MessageFormatRuntimeException(e.getMessage()); } } send(destination, message); return this; }
@Override public JMSProducer send(Destination destination, Map<String, Object> body) { MapMessage message = context.createMapMessage(); if (body != null) { try { for (Entry<String, Object> entry : body.entrySet()) { final String name = entry.getKey(); final Object v = entry.getValue(); if (v instanceof String) { message.setString(name, (String) v); } else if (v instanceof Long) { message.setLong(name, (Long) v); } else if (v instanceof Double) { message.setDouble(name, (Double) v); } else if (v instanceof Integer) { message.setInt(name, (Integer) v); } else if (v instanceof Character) { message.setChar(name, (Character) v); } else if (v instanceof Short) { message.setShort(name, (Short) v); } else if (v instanceof Boolean) { message.setBoolean(name, (Boolean) v); } else if (v instanceof Float) { message.setFloat(name, (Float) v); } else if (v instanceof Byte) { message.setByte(name, (Byte) v); } else if (v instanceof byte[]) { byte[] array = (byte[]) v; message.setBytes(name, array, 0, array.length); } else { message.setObject(name, v); } } } catch (JMSException e) { throw new MessageFormatRuntimeException(e.getMessage()); } } send(destination, message); return this; }
@Override public JMSProducer send(Destination destination, Serializable body) { ObjectMessage message = context.createObjectMessage(body); send(destination, message); return this; }
@Override public JMSProducer send(Destination destination, String body) { TextMessage message = context.createTextMessage(body); send(destination, message); return this; }