You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by ft420 <ar...@gmail.com> on 2009/04/07 09:13:38 UTC
How to send binary data in qpid
Has any one tried sending binary data using qpid. If yes please let me know how to do the same?
Thanks
--
View this message in context: http://n2.nabble.com/How-to-send-binary-data-in-qpid-tp2597387p2597387.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Re: How to send binary data in qpid
Posted by Carl Trieloff <cc...@redhat.com>.
FYI -- I guess you are using
string& assign ( const char* s );
assign your data with
string& assign ( const char* s, size_t n );
................
string& assign ( const string& str );
string& assign ( const string& str, size_t pos, size_t n );
string& assign ( const char* s, size_t n );
string& assign ( const char* s );
string& assign ( size_t n, char c );
template <class InputIterator>
string& assign ( InputIterator first, InputIterator last );
Carl Trieloff wrote:
>
> Sorry, I looked in the wrong place.. how do you assign your data to
> the string object?
>
> Carl.
>
>
> lroloson wrote:
>> When I try to specify the length I get an error "error: no matching
>> function for call to
>> ‘qpid::client::Message::setData(std::string, unsigned int)’".
>>
>> Was the unsigned int parameter implemented after 801239?
>>
>>
>>
>> Larry Roloson
>> TRMI Systems Integration
>>
>> On Oct 20, 2009, at 8:18 AM, Carl Trieloff [via Apache Qpid users]
>> wrote:
>>
>>> lroloson wrote:
>>>
>>>> I have been successful with messages that are strings, but when
>>> trying to
>>>> send binary data, I get the following error;
>>>>
>>>> error: no matching function for call to
>>>> ‘qpid::client::Message::setData(std::string, unsigned int)’. When
>>> I use the
>>>> call the void qpid::client::Message::setData(const std::string&),
>>> the
>>>> message is clipped. qpid-tool shows only 2 bytes are queued. I am
>>> using the
>>>> cpp direct examples compiled and running in Linux (Revision:
>>> 801239).
>>>>
>>>>
>>>>
>>>>
>>>>
>>> If your data has /0 in it then you need to specify the 'unsigned
>>> int' --
>>> length. Did you do this?
>>>
>>> Carl.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> Apache Qpid - AMQP Messaging Implementation
>>> Project: http://qpid.apache.org
>>> Use/Interact: mailto:[hidden email]
>>>
>>>
>>>
>>> View message @
>>> http://n2.nabble.com/Re-How-to-send-binary-data-in-qpid-tp2597473p3858275.html
>>>
>>> To unsubscribe from Re: How to send binary data in qpid, click here.
>>>
>>
>>
>
>
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Re: How to send binary data in qpid
Posted by Carl Trieloff <cc...@redhat.com>.
Sorry, I looked in the wrong place.. how do you assign your data to the
string object?
Carl.
lroloson wrote:
> When I try to specify the length I get an error "error: no matching
> function for call to
> ‘qpid::client::Message::setData(std::string, unsigned int)’".
>
> Was the unsigned int parameter implemented after 801239?
>
>
>
> Larry Roloson
> TRMI Systems Integration
>
> On Oct 20, 2009, at 8:18 AM, Carl Trieloff [via Apache Qpid users]
> wrote:
>
>
>> lroloson wrote:
>>
>>
>>> I have been successful with messages that are strings, but when
>>>
>> trying to
>>
>>> send binary data, I get the following error;
>>>
>>> error: no matching function for call to
>>> ‘qpid::client::Message::setData(std::string, unsigned int)’. When
>>>
>> I use the
>>
>>> call the void qpid::client::Message::setData(const std::string&),
>>>
>> the
>>
>>> message is clipped. qpid-tool shows only 2 bytes are queued. I am
>>>
>> using the
>>
>>> cpp direct examples compiled and running in Linux (Revision:
>>>
>> 801239).
>>
>>>
>>>
>>>
>>>
>>>
>>>
>> If your data has /0 in it then you need to specify the 'unsigned
>> int' --
>> length. Did you do this?
>>
>> Carl.
>>
>>
>> ---------------------------------------------------------------------
>> Apache Qpid - AMQP Messaging Implementation
>> Project: http://qpid.apache.org
>> Use/Interact: mailto:[hidden email]
>>
>>
>>
>> View message @ http://n2.nabble.com/Re-How-to-send-binary-data-in-qpid-tp2597473p3858275.html
>> To unsubscribe from Re: How to send binary data in qpid, click here.
>>
>>
>
>
>
Re: How to send binary data in qpid
Posted by lroloson <lr...@trmi.com>.
When I try to specify the length I get an error "error: no matching
function for call to
‘qpid::client::Message::setData(std::string, unsigned int)’".
Was the unsigned int parameter implemented after 801239?
Larry Roloson
TRMI Systems Integration
On Oct 20, 2009, at 8:18 AM, Carl Trieloff [via Apache Qpid users]
wrote:
> lroloson wrote:
>
> > I have been successful with messages that are strings, but when
> trying to
> > send binary data, I get the following error;
> >
> > error: no matching function for call to
> > ‘qpid::client::Message::setData(std::string, unsigned int)’. When
> I use the
> > call the void qpid::client::Message::setData(const std::string&),
> the
> > message is clipped. qpid-tool shows only 2 bytes are queued. I am
> using the
> > cpp direct examples compiled and running in Linux (Revision:
> 801239).
> >
> >
> >
> >
> >
> >
> >
>
>
> If your data has /0 in it then you need to specify the 'unsigned
> int' --
> length. Did you do this?
>
> Carl.
>
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project: http://qpid.apache.org
> Use/Interact: mailto:[hidden email]
>
>
>
> View message @ http://n2.nabble.com/Re-How-to-send-binary-data-in-qpid-tp2597473p3858275.html
> To unsubscribe from Re: How to send binary data in qpid, click here.
>
--
View this message in context: http://n2.nabble.com/Re-How-to-send-binary-data-in-qpid-tp2597473p3858379.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.
Re: How to send binary data in qpid
Posted by Carl Trieloff <cc...@redhat.com>.
lroloson wrote:
> I have been successful with messages that are strings, but when trying to
> send binary data, I get the following error;
>
> error: no matching function for call to
> ‘qpid::client::Message::setData(std::string, unsigned int)’. When I use the
> call the void qpid::client::Message::setData(const std::string&), the
> message is clipped. qpid-tool shows only 2 bytes are queued. I am using the
> cpp direct examples compiled and running in Linux (Revision: 801239).
>
>
>
>
>
>
>
If your data has /0 in it then you need to specify the 'unsigned int' --
length. Did you do this?
Carl.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Re: How to send binary data in qpid
Posted by lroloson <lr...@trmi.com>.
I have been successful with messages that are strings, but when trying to
send binary data, I get the following error;
error: no matching function for call to
‘qpid::client::Message::setData(std::string, unsigned int)’. When I use the
call the void qpid::client::Message::setData(const std::string&), the
message is clipped. qpid-tool shows only 2 bytes are queued. I am using the
cpp direct examples compiled and running in Linux (Revision: 801239).
--
View this message in context: http://n2.nabble.com/Re-How-to-send-binary-data-in-qpid-tp2597473p3850328.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Re: How to send binary data in qpid
Posted by Alan Conway <ac...@redhat.com>.
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:users-subscribe@qpid.apache.org
Re: How to send binary data in qpid
Posted by qpid_user <kn...@yahoo.com>.
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?
--
View this message in context: http://n2.nabble.com/Re%3A-How-to-send-binary-data-in-qpid-tp2597473p2598870.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Re: How to send binary data in qpid
Posted by Gordon Sim <gs...@redhat.com>.
ft420 wrote:
> Has any one tried sending binary data using qpid. If yes please let me know how to do the same?
Yes; are you using the c++ client? If so then a std::string is just a
sequence of bytes, it need not be restricted to any character set.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org