You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Adel Boutros <Ad...@live.com> on 2016/10/20 12:59:23 UTC
[Proton-c] [0.14.0] C++ sending/receiving bytes and map messages
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);
Regards,
Adel
Re: [Proton-c] [0.14.0] C++ sending/receiving bytes and map messages
Posted by Adel Boutros <Ad...@live.com>.
Jira created: https://issues.apache.org/jira/browse/PROTON-1335
________________________________
From: Adel Boutros <Ad...@live.com>
Sent: Thursday, October 27, 2016 4:02:17 PM
To: Alan Conway; users@qpid.apache.org
Cc: kim.vdriet
Subject: Re: [Proton-c] [0.14.0] C++ sending/receiving bytes and map messages
Adding the mailing list. Otherwise Cliff won't see the mail.
Regards,
Adel
________________________________
From: Alan Conway <ac...@redhat.com>
Sent: Thursday, October 27, 2016 3:35:04 PM
To: Adel Boutros
Cc: kim.vdriet
Subject: Re: [Proton-c] [0.14.0] C++ sending/receiving bytes and map messages
On Thu, 2016-10-27 at 09:36 +0000, Adel Boutros wrote:
> Hello Alan,
>
> I have a very simple reproducible test case for the sendBytes on
> Visual Studio 2008
> Actually, you have to be in "RelWithDebInfo" because in "Debug" mode
> it passes.
>
> PS: I don't have the issue using Visual Studio 2013 (nsvcr90.dll is
> for Visual 2008 if I am not mistaken).
>
> Is Proton supposed to work using Visual Studio 2008? Or do you
> recommend using at least 2013?
We do still support C++03 so in principle it should work. Cliff can you
comment on recommended Windows compilers? The new C++ code may well be
stretching older compilers on template support ;(
I would like to investigate this anyway, old compiler problems
sometimes point to borderline code that might cause trouble in other
circumstances if ignored. Can you make a JIRA?
Thanks,
Alan.
>
> Code
> ----------------
> #include <string>
>
> #include <proton/binary.hpp>
> #include <proton/message.hpp>
>
> int main() {
> proton::message m;
> m.body(proton::binary(std::string("m")));
> //m.body(proton::binary("m"));
> return 0;
> }
>
> Exception
> --------------
> Unhandled exception at 0x623ce2e4 in messaging-feature-tests.dll:
> 0xC0000005: Access violation reading location 0x0000000001479000
>
> Stack
> -----------
> msvcr90.dll!00000000623ce2e4()
> [Frames below may be incorrect and/or missing, no symbols loaded
> for msvcr90.dll]
> > qpid-proton.dll!pn_buffer_append(pn_buffer_t *
> buf=0x000007f7b22842bf, const char * bytes=0x0000000001477cd0,
> unsigned __int64 size=0) Line 174
> C++
> qpid-proton.dll!pni_data_intern(pn_data_t *
> data=0x0000000001477cd0, const char * start=0x00000000014785d0,
> unsigned __int64 size=15595744) Line 437
> C++
> qpid-proton.dll!pni_data_intern_node(pn_data_t *
> data=0x0000000000edf8e0, 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=0x0000000000edf9c0,
> 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=0x000007f7b36edd1f) 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++
> messaging-feature-tests.dll!main() Line 8 + 0x6c bytes
> C++
> messaging-feature-tests.dll!__tmainCRTStartup() Line 582 + 0x19
> bytes
> C
> kernel32.dll!000007f9da961842()
> ntdll.dll!000007f9dcb24f45()
>
> Regards,
> Adel
> From: Alan Conway <ac...@redhat.com>
> Sent: Wednesday, October 26, 2016 7:22:15 PM
> To: Adel Boutros
> Cc: kim.vdriet
> Subject: Re: [Proton-c] [0.14.0] C++ sending/receiving bytes and map
> messages
>
> On Wed, 2016-10-26 at 16:51 +0000, Adel Boutros wrote:
> > Hello Alan,
> >
> > I don't think the sending issues are related to jms.
>
> Agreed. They are definitely C++ bugs and probably my fault :)
>
> > I tried once to isolate a test case for the receiveBytes but I
> wasn't
> > able to reproduce. The bytes were correctly found (I think I was in
> > Debug mode)
> > Tomorrow, I will try again and hopefully have a simple reproducible
> > test case for each of the issues.
>
> > PS: I don't know if this has anything to do with the issues but all
> > the c++ code is loaded in java code using jni and the dlls are
> loaded
> > by calling "System.loadLibrary()" in Java
>
> I can't think of any reason why that would be a problem, but if you
> can't reproduce outside of Java then give me as much information as
> you
> can about how you reproduce it inside Java.
>
>
Re: [Proton-c] [0.14.0] C++ sending/receiving bytes and map messages
Posted by Adel Boutros <Ad...@live.com>.
Adding the mailing list. Otherwise Cliff won't see the mail.
Regards,
Adel
________________________________
From: Alan Conway <ac...@redhat.com>
Sent: Thursday, October 27, 2016 3:35:04 PM
To: Adel Boutros
Cc: kim.vdriet
Subject: Re: [Proton-c] [0.14.0] C++ sending/receiving bytes and map messages
On Thu, 2016-10-27 at 09:36 +0000, Adel Boutros wrote:
> Hello Alan,
>
> I have a very simple reproducible test case for the sendBytes on
> Visual Studio 2008
> Actually, you have to be in "RelWithDebInfo" because in "Debug" mode
> it passes.
>
> PS: I don't have the issue using Visual Studio 2013 (nsvcr90.dll is
> for Visual 2008 if I am not mistaken).
>
> Is Proton supposed to work using Visual Studio 2008? Or do you
> recommend using at least 2013?
We do still support C++03 so in principle it should work. Cliff can you
comment on recommended Windows compilers? The new C++ code may well be
stretching older compilers on template support ;(
I would like to investigate this anyway, old compiler problems
sometimes point to borderline code that might cause trouble in other
circumstances if ignored. Can you make a JIRA?
Thanks,
Alan.
>
> Code
> ----------------
> #include <string>
>
> #include <proton/binary.hpp>
> #include <proton/message.hpp>
>
> int main() {
> proton::message m;
> m.body(proton::binary(std::string("m")));
> //m.body(proton::binary("m"));
> return 0;
> }
>
> Exception
> --------------
> Unhandled exception at 0x623ce2e4 in messaging-feature-tests.dll:
> 0xC0000005: Access violation reading location 0x0000000001479000
>
> Stack
> -----------
> msvcr90.dll!00000000623ce2e4()
> [Frames below may be incorrect and/or missing, no symbols loaded
> for msvcr90.dll]
> > qpid-proton.dll!pn_buffer_append(pn_buffer_t *
> buf=0x000007f7b22842bf, const char * bytes=0x0000000001477cd0,
> unsigned __int64 size=0) Line 174
> C++
> qpid-proton.dll!pni_data_intern(pn_data_t *
> data=0x0000000001477cd0, const char * start=0x00000000014785d0,
> unsigned __int64 size=15595744) Line 437
> C++
> qpid-proton.dll!pni_data_intern_node(pn_data_t *
> data=0x0000000000edf8e0, 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=0x0000000000edf9c0,
> 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=0x000007f7b36edd1f) 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++
> messaging-feature-tests.dll!main() Line 8 + 0x6c bytes
> C++
> messaging-feature-tests.dll!__tmainCRTStartup() Line 582 + 0x19
> bytes
> C
> kernel32.dll!000007f9da961842()
> ntdll.dll!000007f9dcb24f45()
>
> Regards,
> Adel
> From: Alan Conway <ac...@redhat.com>
> Sent: Wednesday, October 26, 2016 7:22:15 PM
> To: Adel Boutros
> Cc: kim.vdriet
> Subject: Re: [Proton-c] [0.14.0] C++ sending/receiving bytes and map
> messages
>
> On Wed, 2016-10-26 at 16:51 +0000, Adel Boutros wrote:
> > Hello Alan,
> >
> > I don't think the sending issues are related to jms.
>
> Agreed. They are definitely C++ bugs and probably my fault :)
>
> > I tried once to isolate a test case for the receiveBytes but I
> wasn't
> > able to reproduce. The bytes were correctly found (I think I was in
> > Debug mode)
> > Tomorrow, I will try again and hopefully have a simple reproducible
> > test case for each of the issues.
>
> > PS: I don't know if this has anything to do with the issues but all
> > the c++ code is loaded in java code using jni and the dlls are
> loaded
> > by calling "System.loadLibrary()" in Java
>
> I can't think of any reason why that would be a problem, but if you
> can't reproduce outside of Java then give me as much information as
> you
> can about how you reproduce it inside Java.
>
>
Re: [Proton-c] [0.14.0] C++ sending/receiving bytes and map messages
Posted by Adel Boutros <ad...@live.com>.
Hello Alan,
I don't think the sending issues are related to jms.
I tried once to isolate a test case for the receiveBytes but I wasn't able to reproduce. The bytes were correctly found (I think I was in Debug mode)
Tomorrow, I will try again and hopefully have a simple reproducible test case for each of the issues.
PS: I don't know if this has anything to do with the issues but all the c++ code is loaded in java code using jni and the dlls are loaded by calling "System.loadLibrary()" in Java
Get Outlook for Android<https://aka.ms/ghei36>
On Wed, Oct 26, 2016 at 6:17 PM +0200, "Alan Conway" <ac...@redhat.com>> wrote:
[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 <ac...@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
Re: [Proton-c] [0.14.0] C++ sending/receiving bytes and map messages
Posted by Alan Conway <ac...@redhat.com>.
[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 <ac...@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
Re: [Proton-c] [0.14.0] C++ sending/receiving bytes and map messages
Posted by Adel Boutros <Ad...@live.com>.
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.
* Stack trace:
> 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=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)));
std::cout << "sendMessage" << std::flush << std::endl;
MessagingSendOneHandler messagingSendHandler(url, msg, connectionOptions, nbOfTimesToSend); //This is the typical handler which sends messages blindly
proton::default_container(messagingSendHandler).run();
std::cout << "sendMessage end" << std::flush << std::endl;
}
* Proton code (It hangs on the first line of the insert method "state_guard constructor":
template <class T, class U>
encoder& encoder::insert(const T& x, int (*put)(pn_data_t*, U)) {
internal::state_guard sg(*this); // Save state in case of error.
check(put(pn_object(), coerce<U>(x)));
sg.cancel(); // Don't restore state, all is good.
return *this;
}
----------------------------------------------
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 <ac...@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/cpp
/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
Re: [Proton-c] [0.14.0] C++ sending/receiving bytes and map messages
Posted by Alan Conway <ac...@redhat.com>.
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/cpp
/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