You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Andreas Welchlin <an...@comyno.com> on 2014/07/18 15:25:55 UTC
QPid 0.28 amqp1.0 - sending map from java to c++ does not work
Hi List,
I used Hello.java from "qpid-java-amqp-1-0-client-jms-0.28.tar.gz" to
send an amqp 1.0 message which contains a map to an exchange.
Java Code:
-------------------------------------------------------------------------------------------------------
MapMessage mapmessage = producersession.createMapMessage();
mapmessage.setStringProperty("hello","true");
mapmessage.setBoolean("mybool", true);
mapmessage.setString("mystring", "hello");
mapmessage.setLong("mylong", -25L);
messageProducer.send(mapmessage);
-------------------------------------------------------------------------------------------------------
This works when I read the message with the java application.
But when I read it with a C++ client (linked qpid 0.28 library) then it
can read the message and dump it as a text but it fails decoding the map.
The c++ client uses "{protocol:amqp1.0}" when the connection is created.
The c++ client is able to decode map messages from other c++ senders
without any problems.
Here is the logfile from the API:
-------------------------------------------------------------------------------------------------------
In ConnectionContext::get(), current=0x7fa0e00036a0
Received message of 241 bytes:
Recorded delivery 0 -> 0x7fa0e00036a0
wakeupDriver()
acknowledging all 1 messages
Setting disposition for delivery 0 -> 0x7fa0e00036a0
wakeupDriver()
tcp:127.0.0.1:5672 encoded 39 bytes from 65535
Exception constructed: Not enough data for field table.
(/home/noname/install/qpid-0.28/qpid-0.28/cpp/src/qpid/framing/FieldTable.cpp:302)
wakeupDriver()
tcp:127.0.0.1:5672 encoded 42 bytes from 65535
tcp:127.0.0.1:5672 decoded 42 bytes from 42
[127.0.0.1:48347-127.0.0.1:5672] TcpTransport closing...
[127.0.0.1:48347-127.0.0.1:5672] Socket closed
Driver stopped
-------------------------------------------------------------------------------------------------------
Does anyone have an idea what is wrong, here?
Andreas
--
Comyno Ltd.
Mainzer Landstrasse 46
60325 Frankfurt
www.comyno.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: QPid 0.28 amqp1.0 - sending map from java to c++ does not work
Posted by Gordon Sim <gs...@redhat.com>.
On 07/21/2014 04:56 PM, Alan Conway wrote:
> On Mon, 2014-07-21 at 13:16 +0100, Gordon Sim wrote:
>> On 07/21/2014 01:12 PM, Andreas Welchlin wrote:
>>> Funny that it seemed to work with "decode()" as long as I only used C++
>>> applications. I think the reason was that the C++ senders used also
>>> "encode()".
>>
>> Yes, that would result in an AMQP 0-10 encoded map (with the content
>> being 'binary' as far as AMQP 1.0 is concerned).
>
> Given that we have multiple incompatible ways to extract data from a
> message, is it possible to detect incorrect use and raise an exception
> rather than just returning nothing?
In this case an exception was raised. The associated message could
certainly be more obvious though, e.g. 'decoding of AMQP 0-10 map
failed' perhaps.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: QPid 0.28 amqp1.0 - sending map from java to c++ does not work
Posted by Alan Conway <ac...@redhat.com>.
On Mon, 2014-07-21 at 13:16 +0100, Gordon Sim wrote:
> On 07/21/2014 01:12 PM, Andreas Welchlin wrote:
> > Funny that it seemed to work with "decode()" as long as I only used C++
> > applications. I think the reason was that the C++ senders used also
> > "encode()".
>
> Yes, that would result in an AMQP 0-10 encoded map (with the content
> being 'binary' as far as AMQP 1.0 is concerned).
Given that we have multiple incompatible ways to extract data from a
message, is it possible to detect incorrect use and raise an exception
rather than just returning nothing? That would help short-cut the
debugging process as people are bound to have mixed systems in the
transition from 0-10 to 1.0 etc.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: QPid 0.28 amqp1.0 - sending map from java to c++ does not work
Posted by Gordon Sim <gs...@redhat.com>.
On 07/21/2014 01:12 PM, Andreas Welchlin wrote:
> Funny that it seemed to work with "decode()" as long as I only used C++
> applications. I think the reason was that the C++ senders used also
> "encode()".
Yes, that would result in an AMQP 0-10 encoded map (with the content
being 'binary' as far as AMQP 1.0 is concerned).
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: QPid 0.28 amqp1.0 - sending map from java to c++ does not work
Posted by Andreas Welchlin <an...@comyno.com>.
Am 21.07.2014 13:52, schrieb Gordon Sim:
> On 07/21/2014 12:28 PM, Andreas Welchlin wrote:
>> No, I am not using getContentObject but the decode function:
>
> Ok, that is the problem. You need to use getContentObject() for AMQP
> 1.0 messages. You can use that for 0-10 also and it works regardless
> of the type of object sent (e.g. binary or utf will also be correctly
> retrieved).
>
> The qpid::messaging::decode() functions only decode 0-10 typed data.
> In AMQP 1.0, rather than using a content-type header to indicate the
> type of the content, the AMQP type system itself is used. This meant
> we had to add something to the API to expose that information. The
> concept of content object was added which indicates the type through
> Variant::getType() but also presents a decoded representation.
......
> The above would be something like:
>
> using namespace qpid::types;
>
> MyMessage::MyMessage(const qpid::messaging::Message &qpidMessage)
> {
> if (qpidMessage.getContentObject().getType() != VAR_MAP)
> {
> THROW(UsrException, "Message content was not a map!");
> }
> Variant::Map map = qpidMessage.getContentObject().asMap();
> mSystemMessageId.assign(map["SytemMsgId"].asString());
> mContent = map["content"].asString();
> }
Oh, I missed this when I was moving to AMQP 1.0.
Funny that it seemed to work with "decode()" as long as I only used C++
applications. I think the reason was that the C++ senders used also
"encode()".
Now I used your code and everything works perfectly, now. (I also
changed the C++ senders to use "setContentObject()".
Thank you very much for your help, Gordon!
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: QPid 0.28 amqp1.0 - sending map from java to c++ does not work
Posted by Gordon Sim <gs...@redhat.com>.
On 07/21/2014 12:28 PM, Andreas Welchlin wrote:
> No, I am not using getContentObject but the decode function:
Ok, that is the problem. You need to use getContentObject() for AMQP 1.0
messages. You can use that for 0-10 also and it works regardless of the
type of object sent (e.g. binary or utf will also be correctly retrieved).
The qpid::messaging::decode() functions only decode 0-10 typed data. In
AMQP 1.0, rather than using a content-type header to indicate the type
of the content, the AMQP type system itself is used. This meant we had
to add something to the API to expose that information. The concept of
content object was added which indicates the type through
Variant::getType() but also presents a decoded representation.
> MyMessage::MyMessage(const qpid::messaging::Message &qpidMessage)
> {
> if (qpidMessage.getContentType() != "amqp/map")
> {
> // When Java Applications send an AMQP/MAP in amqp version 1.0,
> then the string is found
> // in the properties.
> qpid::types::Variant::Map properties =
> qpidMessage.getProperties();
> if (properties["x-opt-jms-type"].asString() != "amqp/map")
> THROW(UsrException, "wrong content type (!= amqp/map): " <<
> qpidMessage.getContentType());
> }
>
> qpid::types::Variant::Map map;
> qpid::messaging::decode(qpidMessage, map);
> mSystemMessageId.assign(map["SytemMsgId"].asString());
> mContent = map["content"].asString();
> }
The above would be something like:
using namespace qpid::types;
MyMessage::MyMessage(const qpid::messaging::Message &qpidMessage)
{
if (qpidMessage.getContentObject().getType() != VAR_MAP)
{
THROW(UsrException, "Message content was not a map!");
}
Variant::Map map = qpidMessage.getContentObject().asMap();
mSystemMessageId.assign(map["SytemMsgId"].asString());
mContent = map["content"].asString();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: QPid 0.28 amqp1.0 - sending map from java to c++ does not work
Posted by Andreas Welchlin <an...@comyno.com>.
Hi Gordon,
Cool!
I tried it and it works.
Thank you very much!
This workaround helps me very much.
Cheers
Andreas
Am 21.07.2014 13:28, schrieb Andreas Welchlin:
> Hi Gordon,
>
> thank you for your answer. I am also using the c++ broker (0.28).
>
> >How are you getting the content using qpid::messaging? Are you using
> Message::getContentObject()?
>
> No, I am not using getContentObject but the decode function:
>
>
> MyMessage::MyMessage(const qpid::messaging::Message &qpidMessage)
> {
> if (qpidMessage.getContentType() != "amqp/map")
> {
> // When Java Applications send an AMQP/MAP in amqp version
> 1.0, then the string is found
> // in the properties.
> qpid::types::Variant::Map properties =
> qpidMessage.getProperties();
> if (properties["x-opt-jms-type"].asString() != "amqp/map")
> THROW(UsrException, "wrong content type (!= amqp/map): "
> << qpidMessage.getContentType());
> }
>
> qpid::types::Variant::Map map;
> qpid::messaging::decode(qpidMessage, map);
> mSystemMessageId.assign(map["SytemMsgId"].asString());
> mContent = map["content"].asString();
> }
>
> Regards,
> Andreas
>
>
> Am 21.07.2014 13:20, schrieb Gordon Sim:
>> On 07/18/2014 02:25 PM, Andreas Welchlin wrote:
>>> Hi List,
>>>
>>> I used Hello.java from "qpid-java-amqp-1-0-client-jms-0.28.tar.gz" to
>>> send an amqp 1.0 message which contains a map to an exchange.
>>>
>>> Java Code:
>>> -------------------------------------------------------------------------------------------------------
>>>
>>>
>>> MapMessage mapmessage = producersession.createMapMessage();
>>> mapmessage.setStringProperty("hello","true");
>>> mapmessage.setBoolean("mybool", true);
>>> mapmessage.setString("mystring", "hello");
>>> mapmessage.setLong("mylong", -25L);
>>> messageProducer.send(mapmessage);
>>> -------------------------------------------------------------------------------------------------------
>>>
>>>
>>>
>>> This works when I read the message with the java application.
>>>
>>> But when I read it with a C++ client (linked qpid 0.28 library) then it
>>> can read the message and dump it as a text but it fails decoding the
>>> map.
>>> The c++ client uses "{protocol:amqp1.0}" when the connection is
>>> created.
>>> The c++ client is able to decode map messages from other c++ senders
>>> without any problems.
>>
>> It works for me when using the 0.28 version of both jms and c++
>> client libraries, and the c++ broker.
>>
>> How are you getting the content using qpid::messaging? Are you using
>> Message::getContentObject()?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
>> For additional commands, e-mail: users-help@qpid.apache.org
>>
>
--
Comyno Ltd.
Mainzer Landstrasse 46
60325 Frankfurt
www.comyno.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: QPid 0.28 amqp1.0 - sending map from java to c++ does not work
Posted by Andreas Welchlin <an...@comyno.com>.
Hi Gordon,
thank you for your answer. I am also using the c++ broker (0.28).
>How are you getting the content using qpid::messaging? Are you using
Message::getContentObject()?
No, I am not using getContentObject but the decode function:
MyMessage::MyMessage(const qpid::messaging::Message &qpidMessage)
{
if (qpidMessage.getContentType() != "amqp/map")
{
// When Java Applications send an AMQP/MAP in amqp version 1.0,
then the string is found
// in the properties.
qpid::types::Variant::Map properties = qpidMessage.getProperties();
if (properties["x-opt-jms-type"].asString() != "amqp/map")
THROW(UsrException, "wrong content type (!= amqp/map): " <<
qpidMessage.getContentType());
}
qpid::types::Variant::Map map;
qpid::messaging::decode(qpidMessage, map);
mSystemMessageId.assign(map["SytemMsgId"].asString());
mContent = map["content"].asString();
}
Regards,
Andreas
Am 21.07.2014 13:20, schrieb Gordon Sim:
> On 07/18/2014 02:25 PM, Andreas Welchlin wrote:
>> Hi List,
>>
>> I used Hello.java from "qpid-java-amqp-1-0-client-jms-0.28.tar.gz" to
>> send an amqp 1.0 message which contains a map to an exchange.
>>
>> Java Code:
>> -------------------------------------------------------------------------------------------------------
>>
>>
>> MapMessage mapmessage = producersession.createMapMessage();
>> mapmessage.setStringProperty("hello","true");
>> mapmessage.setBoolean("mybool", true);
>> mapmessage.setString("mystring", "hello");
>> mapmessage.setLong("mylong", -25L);
>> messageProducer.send(mapmessage);
>> -------------------------------------------------------------------------------------------------------
>>
>>
>>
>> This works when I read the message with the java application.
>>
>> But when I read it with a C++ client (linked qpid 0.28 library) then it
>> can read the message and dump it as a text but it fails decoding the
>> map.
>> The c++ client uses "{protocol:amqp1.0}" when the connection is created.
>> The c++ client is able to decode map messages from other c++ senders
>> without any problems.
>
> It works for me when using the 0.28 version of both jms and c++ client
> libraries, and the c++ broker.
>
> How are you getting the content using qpid::messaging? Are you using
> Message::getContentObject()?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>
--
Comyno Ltd.
Mainzer Landstrasse 46
60325 Frankfurt
www.comyno.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: QPid 0.28 amqp1.0 - sending map from java to c++ does not work
Posted by Gordon Sim <gs...@redhat.com>.
On 07/18/2014 02:25 PM, Andreas Welchlin wrote:
> Hi List,
>
> I used Hello.java from "qpid-java-amqp-1-0-client-jms-0.28.tar.gz" to
> send an amqp 1.0 message which contains a map to an exchange.
>
> Java Code:
> -------------------------------------------------------------------------------------------------------
>
> MapMessage mapmessage = producersession.createMapMessage();
> mapmessage.setStringProperty("hello","true");
> mapmessage.setBoolean("mybool", true);
> mapmessage.setString("mystring", "hello");
> mapmessage.setLong("mylong", -25L);
> messageProducer.send(mapmessage);
> -------------------------------------------------------------------------------------------------------
>
>
> This works when I read the message with the java application.
>
> But when I read it with a C++ client (linked qpid 0.28 library) then it
> can read the message and dump it as a text but it fails decoding the map.
> The c++ client uses "{protocol:amqp1.0}" when the connection is created.
> The c++ client is able to decode map messages from other c++ senders
> without any problems.
It works for me when using the 0.28 version of both jms and c++ client
libraries, and the c++ broker.
How are you getting the content using qpid::messaging? Are you using
Message::getContentObject()?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: QPid 0.28 amqp1.0 - sending map from java to c++ does not work
Posted by Gordon Sim <gs...@redhat.com>.
On 07/21/2014 10:14 AM, Andreas Welchlin wrote:
> I found one more strange behaviour between Java and C++ when using AMQP
> 1.0:
>
> When a java application sets properties they are invisible for the c++
> client:
[...]
> Do you think this is a bug in QPID or is there something wrong with my
> code?
That is indeed a bug I'm afraid, thanks for taking the time to report it.
What is happening is that the properties are being replaced by the
annotations in the message from JMS, whereas the annotations are
supposed to be merged into the properties as presented to the application.
There is a workaround that you can use for now. If you set a connection
property (on the c++ client) called "nest_annotations" to true, then you
will see the application properties as sent by JMS. (The annotations in
this case are then included as nested maps).
I've raised https://issues.apache.org/jira/browse/QPID-5908 to track
this and will get a fix in shortly.
Thanks again!
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: QPid 0.28 amqp1.0 - sending map from java to c++ does not work
Posted by Andreas Welchlin <an...@comyno.com>.
Hi All,
I found one more strange behaviour between Java and C++ when using AMQP 1.0:
When a java application sets properties they are invisible for the c++
client:
*** java sender sends a text message with a property:
MessageProducer messageProducer = producersession.createProducer(topic);
TextMessage message = producersession.createTextMessage("Hello world!");
message.setJMSType("Hello");
message.setStringProperty("testproperty","ttt"); // invisible for
C++ Client
messageProducer.send(message);
*** The java receiver prints:
Received text Message:
======================
Hello world!
testproperty: ttt
*** The c++ receiver prints:
2014-07-21 10:45:54.55301 [12359.140273439021248] INFO qpid msg - AMQP
MESSAGE ==============================================================
2014-07-21 10:45:54.55305 [12359.140273439021248] INFO qpid msg - AMQP
Header:
2014-07-21 10:45:54.55307 [12359.140273439021248] INFO qpid msg -
Subject..........:
2014-07-21 10:45:54.55308 [12359.140273439021248] INFO qpid msg -
content type.....:
2014-07-21 10:45:54.55325 [12359.140273439021248] INFO qpid msg -
content size.....: 12
2014-07-21 10:45:54.55326 [12359.140273439021248] INFO qpid msg -
message id.......: 2714741a-540f-4d88-997f-39d720621540
2014-07-21 10:45:54.55328 [12359.140273439021248] INFO qpid msg - user
id..........:
2014-07-21 10:45:54.55329 [12359.140273439021248] INFO qpid msg -
correlation id...:
2014-07-21 10:45:54.55331 [12359.140273439021248] INFO qpid msg -
priority.........: 4
2014-07-21 10:45:54.55332 [12359.140273439021248] INFO qpid msg - time
to live (ms): 0
2014-07-21 10:45:54.55333 [12359.140273439021248] INFO qpid msg -
durable..........: yes
2014-07-21 10:45:54.55334 [12359.140273439021248] INFO qpid msg -
redelivered......: 0
2014-07-21 10:45:54.55335 [12359.140273439021248] INFO qpid msg - reply
to.........:
2014-07-21 10:45:54.55336 [12359.140273439021248] INFO qpid msg - Custom
Properties:
2014-07-21 10:45:54.55339 [12359.140273439021248] INFO qpid msg -
qpid.msg_sequence..: 10
2014-07-21 10:45:54.55340 [12359.140273439021248] INFO qpid msg -
x-opt-jms-type..: Hello <==== OK, the JMS Type can be read as
a property
2014-07-21 10:45:54.55341 [12359.140273439021248] INFO qpid msg -
x-opt-to-type..: topic
2014-07-21 10:45:54.55342 [12359.140273439021248] INFO qpid msg - Content:
2014-07-21 10:45:54.55343 [12359.140273439021248] INFO qpid msg - Hello
world! <==== OK, the text content can be read
2014-07-21 10:45:54.55344 [12359.140273439021248] INFO qpid msg - End
AMQP MESSAGE ==========================================================
The property "testproperty" is not visible using this code:
typedef qpid::types::Variant::Map::const_iterator QpidMapCIt;
void getProperties(const qpid::messaging::Message &msg, FieldVec &fields)
{
qpid::types::Variant::Map properties = msg.getProperties();
for (QpidMapCIt it = properties.begin(); it != properties.end(); ++it)
{
fields.push_back(MsgField(it->first, it->second.asString()));
}
}
Do you think this is a bug in QPID or is there something wrong with my code?
Regards,
Andreas
Am 18.07.2014 15:25, schrieb Andreas Welchlin:
> Hi List,
>
> I used Hello.java from "qpid-java-amqp-1-0-client-jms-0.28.tar.gz" to
> send an amqp 1.0 message which contains a map to an exchange.
>
> Java Code:
> -------------------------------------------------------------------------------------------------------
>
> MapMessage mapmessage = producersession.createMapMessage();
> mapmessage.setStringProperty("hello","true");
> mapmessage.setBoolean("mybool", true);
> mapmessage.setString("mystring", "hello");
> mapmessage.setLong("mylong", -25L);
> messageProducer.send(mapmessage);
> -------------------------------------------------------------------------------------------------------
>
>
> This works when I read the message with the java application.
>
> But when I read it with a C++ client (linked qpid 0.28 library) then
> it can read the message and dump it as a text but it fails decoding
> the map.
> The c++ client uses "{protocol:amqp1.0}" when the connection is created.
> The c++ client is able to decode map messages from other c++ senders
> without any problems.
>
> Here is the logfile from the API:
> -------------------------------------------------------------------------------------------------------
>
> In ConnectionContext::get(), current=0x7fa0e00036a0
> Received message of 241 bytes:
> Recorded delivery 0 -> 0x7fa0e00036a0
> wakeupDriver()
> acknowledging all 1 messages
> Setting disposition for delivery 0 -> 0x7fa0e00036a0
> wakeupDriver()
> tcp:127.0.0.1:5672 encoded 39 bytes from 65535
> Exception constructed: Not enough data for field table.
> (/home/noname/install/qpid-0.28/qpid-0.28/cpp/src/qpid/framing/FieldTable.cpp:302)
> wakeupDriver()
> tcp:127.0.0.1:5672 encoded 42 bytes from 65535
> tcp:127.0.0.1:5672 decoded 42 bytes from 42
> [127.0.0.1:48347-127.0.0.1:5672] TcpTransport closing...
> [127.0.0.1:48347-127.0.0.1:5672] Socket closed
> Driver stopped
> -------------------------------------------------------------------------------------------------------
>
>
> Does anyone have an idea what is wrong, here?
>
> Andreas
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org