qpid_user wrote:
I have a struct xyz to be sent. I did try sending it in following way message.setData((const char*)xyz); // sends incomplete data, upto '\0' character.

Hi Gordon You seem to have sent binary data. If you don't mind would you please let me know how to send the binary data using qpid...

say i want to send/recv  xyz structure on message queue. how do we do the same?


You can do something like this:

struct Foo {...};
Foo foo;
message.setData(std::string(reinterpret_cast<const char*>(&foo), sizeof(foo));
...
foo = *reinterpret_cast<const Foo*>(message.getData());

PROVIDED that all the hosts in your cluster have identical architecture. This is a highly non-portable way to encode things and can fail tragically if any of your hosts have different architecture or if you have different versions of the client built with different compilers versions or even different compiler flags.

For more portable alternatives, you can use the qpid::framing::Buffer to encode things, but you have to write the code to serialize your structure into calls on the Buffer put/get functions. This is not really part of the client API so it may change in future

For a more full-featured serialization framework you might want to check out boost.serialization.

Cheers,
Alan.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to