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 <[email protected]>
Sent: Tuesday, October 25, 2016 8:30 PM
To: [email protected]
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: [email protected]
For additional commands, e-mail: [email protected]