-
1. Re: Sending custom objects with HornetQ Core
clebert.suconic Dec 9, 2010 9:41 AM (in response to d.smelanskij)I have now idea what you're doing on getMyMessage();
Why don't you just send a Message with a specific body.
You're probably doing something inside MyMessageType. I would just use the regular message type if I were you.
-
2. Re: Sending custom objects with HornetQ Core
d.smelanskij Dec 10, 2010 2:54 AM (in response to clebert.suconic)sorry,
may be my question was wrong.
I try to redefine it.
I have a HornetQ core client and HornetQ core server. Connection configured by using NettyAcceptorFactory
as a Message to send is MyMessageType<?>
When I am using JBoss Netty, I send messages using ChannelBuffer, with channelBuffer.writeBytes(myMessageType.toBytes());
When I am using JBoss ESB , I send messages using esbMessage.getBody().add(myMessage);
How do I send and receive complex custom messages using HornetQ, I have not found any example.
-
3. Re: Sending custom objects with HornetQ Core
d.smelanskij Dec 10, 2010 4:14 AM (in response to d.smelanskij)After reading the API, found right solution:
Sender:
ClientMessage cMessage = session.createMessage(false);
TestMessage testMessage = getTestMessage();
cMessage.getBodyBuffer().writeBytes(toByteArray(testMessage));
producer.send(cMessage);Receiver:
public void onMessage(ClientMessage message) {
byte[] bMessage = new byte[message.getBodySize()]message.getBodyBuffer().readBytes(bMessage);
TestMessage<?> testMessage = (TestMessage<?>) toObject(bMessage);}
-
4. Re: Sending custom objects with HornetQ Core
jendo Jul 7, 2011 3:52 PM (in response to d.smelanskij)Is this the only way to send custom objects?
-
5. Re: Sending custom objects with HornetQ Core
clebert.suconic Jul 8, 2011 12:08 AM (in response to jendo)That's actually what happens when you send ObjectMessage.
In Messaging terms actually there is no such thing as sending objects, we always send byte arrays. (That will be the same with any messaging system). The JMS spec however requires us to have these "utilities" messages, but underneath everything sent is always a message byte array.