ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oout;
try {
oout = new ObjectOutputStream(baos);
oout.writeObject(object);
ClientMessage message = session.createMessage(true);
message.getBodyBuffer().writeBytes(baos.toByteArray());
message.putStringProperty("producerId", name);
producer.send(message);
} catch (IOException e) {
throw new RuntimeException("Error creating message", e);
} catch (HornetQException e) {
throw new RuntimeException("Error writing message", e);