qpid cpp text message

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

qpid cpp text message

plsph
hi
when sending message by qpid proton writen in c, by default the message is text message and i can recieve it with amqp broker in jms format, but when i try to send message by qpid-cpp library it is always binary message, despite message.setcontent("jms-type")

anyone have an idea how to transform binary message to text?
thx in advance
Reply | Threaded
Open this post in threaded view
|

Re: qpid cpp text message

tabish121@gmail.com
On 07/09/2015 04:40 AM, plsph wrote:

> hi
> when sending message by qpid proton writen in c, by default the message is
> text message and i can recieve it with amqp broker in jms format, but when i
> try to send message by qpid-cpp library it is always binary message, despite
> message.setcontent("jms-type")
>
> anyone have an idea how to transform binary message to text?
> thx in advance
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/qpid-cpp-text-message-tp4698876.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>
Can you shed some additional light on what you are doing, what client's
you use, what broker version etc.

By default the pre-5.12 brokers will be using the NATIVE transformer for
AMQP messages meaning that the messages will be received by the openwire
client as BytesMessage types.  If you want full protocol interop you
need to change to the JMS transformer.

http://activemq.apache.org/amqp.html

--
Tim Bish
Sr Software Engineer | RedHat Inc.
[hidden email] | www.redhat.com
twitter: @tabish121
blog: http://timbish.blogspot.com/

Reply | Threaded
Open this post in threaded view
|

Re: qpid cpp text message

Robbie Gemmell
On 9 July 2015 at 14:23, Timothy Bish <[hidden email]> wrote:

> On 07/09/2015 04:40 AM, plsph wrote:
>> hi
>> when sending message by qpid proton writen in c, by default the message is
>> text message and i can recieve it with amqp broker in jms format, but when i
>> try to send message by qpid-cpp library it is always binary message, despite
>> message.setcontent("jms-type")
>>
>> anyone have an idea how to transform binary message to text?
>> thx in advance
>>
>>
>>
>> --
>> View this message in context: http://activemq.2283324.n4.nabble.com/qpid-cpp-text-message-tp4698876.html
>> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>>
> Can you shed some additional light on what you are doing, what client's
> you use, what broker version etc.
>
> By default the pre-5.12 brokers will be using the NATIVE transformer for
> AMQP messages meaning that the messages will be received by the openwire
> client as BytesMessage types.  If you want full protocol interop you
> need to change to the JMS transformer.
>
> http://activemq.apache.org/amqp.html
>
> --
> Tim Bish
> Sr Software Engineer | RedHat Inc.
> [hidden email] | www.redhat.com
> twitter: @tabish121
> blog: http://timbish.blogspot.com/
>

From looking at
http://mail-archives.apache.org/mod_mbox/qpid-users/201409.mbox/%3c540DB537.3010906@...%3e

I think whats needed might be using the 'setContentObject' method
instead so the sending client can actually tell that it is a utf8
string rather than bytes and encode it accordingly.

Robbie
Reply | Threaded
Open this post in threaded view
|

Re: qpid cpp text message

plsph
it doesn't work with setContentObject, there should be msg.getContentObject().setEncoding()
but it still doesn't help with my issue.
i use qpid-cpp 0.32, activemq 11.1
code is something like:

Message msg(content);
msg.setContentType() <- i was trying everything, jms-type, text/plain
msg.getContentObject().setEncoding()
sender.send(msg)


on the broker site, there is setting:
<transportConnector name="amqp" uri="amqp://0.0.0.0:5672?transport.transformemr=jms"/>

thanks
Reply | Threaded
Open this post in threaded view
|

Re: qpid cpp text message

Robbie Gemmell
You dont actually seem to be calling setContentObject at all in the
snippet below, but look to be constructing it with it. Did you try
setting the content using setContentObject instead?

My take from reading previous posts on the subject (such as the one
linked previously, by the person who wrote much of that client) is
that you should call setContentObject and ensure the encoding of that
value is utf8 using setEncoding("utf8"), which should be sufficient to
make the client emit an AMQP string in the body. Following that, I
don't think you need the setContentType call at all.

Robbie

On 12 July 2015 at 20:03, plsph <[hidden email]> wrote:

> it doesn't work with setContentObject, there should be
> msg.getContentObject().setEncoding()
> but it still doesn't help with my issue.
> i use qpid-cpp 0.32, activemq 11.1
> code is something like:
>
> Message msg(content);
> msg.setContentType() <- i was trying everything, jms-type, text/plain
> msg.getContentObject().setEncoding()
> sender.send(msg)
>
>
> on the broker site, there is setting:
> <transportConnector name="amqp"
> uri="amqp://0.0.0.0:5672?transport.transformemr=jms"/>
>
> thanks
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/qpid-cpp-text-message-tp4698876p4699111.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: qpid cpp text message

Gordon Sim-2
In reply to this post by plsph
On 07/12/2015 08:03 PM, plsph wrote:

> it doesn't work with setContentObject, there should be
> msg.getContentObject().setEncoding()
> but it still doesn't help with my issue.
> i use qpid-cpp 0.32, activemq 11.1
> code is something like:
>
> Message msg(content);
> msg.setContentType() <- i was trying everything, jms-type, text/plain
> msg.getContentObject().setEncoding()
> sender.send(msg)

Try:

Message msg;
msg.setContentObject(content);
msg.getContentObject().setEncoding("utf8");
sender.send(msg)

Reply | Threaded
Open this post in threaded view
|

Re: qpid cpp text message

plsph
it still gives BytesMessage
 probably, the problem is with:

If the transformer is set to 'jms', the they type of JMS message will depend on the body type of the AMQP message.

Body Type                              JMS Message Type
null                                           Message
Data                                            BytesMessage
AmqpSequence                        StreamMessage
AmqpValue holding a null               Message
AmqpValue holding a String         TextMessage
AmqpValue holding a binary         BytesMessage
AmqpValue holding a list           StreamMessage
AmqpValue                            ObjectMessage

so how to craft amqpvalue ?
Reply | Threaded
Open this post in threaded view
|

Re: qpid cpp text message

Robbie Gemmell
On 14 July 2015 at 13:52, plsph <[hidden email]> wrote:

> it still gives BytesMessage
>  probably, the problem is with:
>
> If the transformer is set to 'jms', the they type of JMS message will depend
> on the body type of the AMQP message.
>
> Body Type                              JMS Message Type
> null                                           Message
> Data                                            BytesMessage
> AmqpSequence                        StreamMessage
> AmqpValue holding a null               Message
> AmqpValue holding a String         TextMessage
> AmqpValue holding a binary         BytesMessage
> AmqpValue holding a list           StreamMessage
> AmqpValue                            ObjectMessage
>
> so how to craft amqpvalue ?
>
>

The changes Gordon and I suggested were precisely to make the client
send an AmqpValue body containing a string, rather than the
alternative it defaults to for non-utf8 content or content not set
using 'setContentObject'.

Looking back at your earlier messages I noticed something I missed before:
> on the broker site, there is setting:
> <transportConnector name="amqp"
> uri="amqp://0.0.0.0:5672?transport.transformemr=jms"/>

You have a typo in your connector config: "transformemr" instead of
"transformer". As a result, it is likely not using the 'jms' one at
all, but rather the 'native' one, which possibly means you have a
warning in your broker log about that. The 'native' transformer makes
things a BytesMessage internally within the broker to carry the
original AMQP message payload bytes, which should go back out to an
AMQP consumer without issue, but would show up to a non-AMQP consumer
as a BytesMessage with somewhat odd content. I'm not sure you have
actually indicated thus far what particular consumers you are using
however.

Robbie
Reply | Threaded
Open this post in threaded view
|

Re: qpid cpp text message

plsph
it was typo during rewrite. broker settings are fine. i don't know what the consumer is. i only got producer and broker.
it's hard to argue with statement that it should work. i've used qpid-proton writen in c and i was able to send messages to jms transformer and they were recieved as text messages. now, using the same infrastructure and qpid-cpp i always get bytes message, none of above examples crafted text message.
Reply | Threaded
Open this post in threaded view
|

Re: qpid cpp text message

Gordon Sim-2
On 07/15/2015 08:51 PM, plsph wrote:
> it was typo during rewrite. broker settings are fine. i don't know what the
> consumer is. i only got producer and broker.
> it's hard to argue with statement that it should work. i've used qpid-proton
> writen in c and i was able to send messages to jms transformer and they were
> recieved as text messages. now, using the same infrastructure and qpid-cpp i
> always get bytes message, none of above examples crafted text message.

Could you get a protocol trace from the client (or indeed the broker or
a tcpdump)? On the client setting the environment variable is a simple
way of doing this, e.g. QPID_LOG_ENABLE=trace+:Protocol

That will show exactly what is being sent which will show which side the
problem is on.

Reply | Threaded
Open this post in threaded view
|

Re: qpid cpp text message

Robbie Gemmell
In reply to this post by plsph
On 15 July 2015 at 20:51, plsph <[hidden email]> wrote:
> it was typo during rewrite. broker settings are fine. i don't know what the
> consumer is. i only got producer and broker.
> it's hard to argue with statement that it should work. i've used qpid-proton
> writen in c and i was able to send messages to jms transformer and they were
> recieved as text messages. now, using the same infrastructure and qpid-cpp i
> always get bytes message, none of above examples crafted text message.
>
>

For what its worth, I happened to be using the C++ client (from trunk
as of 0.34 timeframe) myself today, and in doing so confirmed that
changing its hello_world.cpp example from doing this:

    sender.send(Message("Hello world!"));

To doing this:

    Message msg;
    msg.setContentObject("Hello World!");
    msg.getContentObject().setEncoding("utf8");
    sender.send(msg);

Resulted in the payload sent by the client when using AMQP 1.0
changing from a data body section containing bytes to an amqp-value
body section containing a utf8 string.

Enabling the logging that Gordon mentioned in his last reply should
help you confirm if the same is true in your case. If it is, then it
would likely point to a broker config issue, or perhaps something with
the receiving client.

I'll be starting a thread on the qpid lists to enquire if there is any
reason not to change the hello_world example to use setContentObject,
given the other examples appear to do so already.

Robbie
Reply | Threaded
Open this post in threaded view
|

Re: qpid cpp text message

plsph
no i see on the broker that messages are text by ./bin/activemq browse
for what it's worth i've used iconv object and parsed it directly to msg.setContentObject. now i make std::string out of it and then feed it to msg.setContentObject

thank You all for help