qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Conway <acon...@redhat.com>
Subject Re: [Proton-c] [0.14.0] C++ sending/receiving bytes and map messages
Date Wed, 26 Oct 2016 16:16:07 GMT
[CCd Kim: can you comment on the JMS interop problems Adel mentions
below? I don't know if you're there yet in your interop tests]


On Wed, 2016-10-26 at 15:52 +0000, Adel Boutros wrote:
> Thank you Alan for your valuable input!
> 
> 
> I am actually having problems on Windows (RelWithDebInfo mode) when
> using Bytes or Map message.
> 
> This is passing on Solaris and Linux.
> 
> 
> Here is what I have so far:
> 
> 
> Sending BytesMessage from Proton-c
> 
> ----------------------------------------------------------
> 
> * It hangs on the call to encoder::insert while trying to get a lock
> on "*this". It seems the lock is acquired somewhere but never
> released.

That is definitely a C++ bug, can you put all this info on a JIRA and
assign it to me? If you can attach a self-contained program that shows
the hang that will speed things up. A couple more comments inline...

> * Stack trace:
> 
> > 
> > qpid-proton-
> > cpp.dll!proton::codec::encoder::insert<proton::binary,proton::binar
> > y const & __ptr64>(const proton::binary & x={...}, int (pn_data_t
> > *, const proton::binary &)* put=0x000007fb4164dd1f)  Line 121 +
> > 0x11 bytes C++
> 
> * Client code
> void sendBytes(const unsigned char* buffer, const int& len)
> {
>    std::cout << "sendBytes" << std::flush << std::endl;
>    proton::message m;
>    const char* signedStr = reinterpret_cast<const char*>(buffer);
>    m.body(proton::binary(std::string(signedStr, len)));

This code is all fine. FYI you can avoid the extra copy to std::string
like this:

uint8_t* bytes = reinterpret_cast<uint8_t*>(buffer);
m.body(proton::binary(bytes, bytes+len));

But that has nothing to do with the problem you are seeing, just a tip.

> ----------------------------------------------
> Receiving BytesMessage by Proton-c (Sent by JMS)
> -----------------------------------------------
> * It seems to receive an empty "proton::binary"  however
> "message.body().as_string()" has value.
> For more info, please check :
> http://qpid.2158936.n2.nabble.com/Proton-c-0-14-0-Visual-Studio-
> Unable-to-extract-bytes-from-a-BytesMessage-sent-by-JMS-
> td7652317.html

> ----------------------------------------------
> Sending MapMessage by Proton-c
> -----------------------------------------------
> * Same hanging as BytesMessage but I have a different stack
> * Code (buffer.c) The  while loop is called indefinitely loop it
> seems
> while (pn_buffer_available(buf) < size) {
>     buf->capacity = 2*(buf->capacity ? buf->capacity : 16);
>   }
> * stack
> 
>   qpid-proton.dll!pn_buffer_ensure(pn_buffer_t *
> buf=0xffffffffe8ede5d1, unsigned __int64 size=387062319)  Line 145
> C++
>   qpid-proton.dll!pn_buffer_append(pn_buffer_t *
> buf=0x00000000021ecce8, const char * bytes=0x0000000017120ad0,
> unsigned __int64 size=0)  Line 167 C++
>   qpid-proton.dll!pni_data_intern(pn_data_t *
> data=0x0000000017120ad0, const char * start=0x0000000017118890,
> unsigned __int64 size=35573120)  Line 437 C++
>   qpid-proton.dll!pni_data_intern_node(pn_data_t *
> data=0x00000000021ecd80, pni_node_t * node=0x0000000000000000)  Line
> 470 + 0x12 bytes C++
>   qpid-proton-cpp.dll!proton::codec::`anonymous
> namespace'::pn_data_put_amqp_binary(pn_data_t * d=0x00000000021ece68,
> const proton::binary & x={...})  Line 114 + 0x55 bytes C++
>   qpid-proton-
> cpp.dll!proton::codec::encoder::insert<proton::binary,proton::binary
> const & __ptr64>(const proton::binary & x={...}, int (pn_data_t *,
> const proton::binary &)* put=0x000007f9d00edd1f)  Line 121 + 0x11
> bytes C++
>   messaging-feature-
> tests.dll!proton::value::operator=<proton::binary>(const
> proton::binary & x={...})  Line 88 C++
> > 
> > messaging-feature-
> > tests.dll!proton::value::value<proton::binary>(const proton::binary
> > & x={...}, void * __formal=0x0000000000000000)  Line 82 + 0x3f
> > bytes C++
> 
> * Send map code
> 
>    std::map<std::string, proton::value> values;
> 
>    values["keyString"] = "value";
>    values["keyInt"] = maxIntegerValue;
>    values["keyLong"] = maxLongValue;
> 
>    proton::message m;
>    m.body(values);
> 
>    int8_t jmsMapMessageType = 2;
>    m.message_annotations().put("x-opt-jms-msg-type",
> jmsMapMessageType);
>    sendMessage(m, nbOfTimesToSend);
> 
> 
> 
> Regards,
> 
> Adel
> 
> 
> ________________________________
> From: Alan Conway <aconway@redhat.com>
> Sent: Tuesday, October 25, 2016 8:30 PM
> To: users@qpid.apache.org
> Subject: Re: [Proton-c] [0.14.0] C++ sending/receiving bytes and map
> messages
> 
> On Thu, 2016-10-20 at 12:59 +0000, Adel Boutros wrote:
> > 
> > Hello,
> > 
> > 
> > It seems with 0.12.2, we were able to receive a bytes message by
> > using (msg.body.get(std::string)). However it seems this is no
> > longer
> > the case on 0.14.0.
> > 
> > 
> > I was wondering if there is there an example which explain how to
> > send bytes and map messages?
> > 
> > 
> > I found the below code for bytes in reactor_send.cpp :
> > 
> >         proton::binary content;
> >         content.assign((size_t) size, 'X');
> >         message_.body(content);
> > 
> 
> examples/cpp/simple_send.cpp sends a map, the proton::binary type is
> the right way to send bytes. examples/cpp/encode_decode.cpp shows how
> to convert a variety of C++ types to/from a proton::value, which is
> the
> type used to set/get the message body. There is also some discussion
> in
> the docs https://qpid.apache.org/releases/qpid-proton-0.15.0/proton/c
> pp
> /api/md_types.html
> 
> Please shout if you have more questions or suggestions to improve the
> doc/examples.
> 
> Cheers,
> Alan.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Mime
View raw message