You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Davide Anastasia <Da...@qualitycapital.com> on 2012/01/26 12:10:38 UTC
Differences between Message classes in Qpid C++ API
Hi,
Can anybody explain me what the difference between
qpid::messaging::Message and qpid::client::Message is?
I am trying to use VariantMap into the pub/sub example, but encode( ) is
only supported for qpid::messaging::Message.
Best,
Davide Anastasia
Analyst, Research & Development
Quality Capital Management Ltd.
QCM House * Horizon Business Village
No. 1 Brooklands Road
Weybridge * Surrey KT13 0TJ
United Kingdom
Tel: +44 (0) 1932 334 400
Fax: +44 (0) 1932 334 415
Email: Davide.Anastasia@QualityCapital.com
<ma...@QualityCapital.com>
www.qualitycapital.com <http://www.qualitycapital.com/>
________________________________
This email and any attachments are confidential and intended solely for
the use of the individual(s) to whom it is addressed.
Any views or opinions presented are solely those of the author and do
not necessarily represent those of Quality Capital Management Ltd. If
you are not the intended recipient, be advised that you have received
this email in error and that any use, dissemination, printing,
forwarding or copying of this email is strictly prohibited. Please
contact the sender if you have received this email in error. You should
also be aware that emails are susceptible to interference and you should
not assume that the contents of this email originated from the sender
above or that they have been accurately reproduced in their original
form. Quality Capital Management Ltd is authorised and regulated by the
Financial Services Authority in the UK and is a member of the National
Futures Association in the US.
________________________________
RE: Differences between Message classes in Qpid C++ API
Posted by Davide Anastasia <Da...@qualitycapital.com>.
Thanks a lot, your snippet was really useful.
Best,
D.
-----Original Message-----
From: Virgilio Fornazin [mailto:virgiliofornazin@gmail.com]
Sent: 26 January 2012 19:53
To: users@qpid.apache.org
Subject: Re: Differences between Message classes in Qpid C++ API
Davide
It´s very CPU and resource intensive. We use RedHat MRG (qpid 0.10) here, and we ended-up creating specific receivers for each exchange type, and using specific receiver for specific exchange in our middleware abstraction code in this way...
<code>
qpid_context->m_direct_sender = qpid_context->m_session.createSender("amq.direct");
qpid_context->m_topic_sender = qpid_context->m_session.createSender("amq.topic");
qpid_context->m_fanout_sender = qpid_context->m_session.createSender("amq.fanout");
</code>
when we need to send a message to a direct key, we use the code
<code>
sender_reference_type get_sender(const destination &
destination)
{
check_connection_state();
switch (destination.type())
{
case destination_type::queue:
{
return m_direct_sender;
}
case destination_type::topic:
{
return m_topic_sender;
}
case destination_type::broadcast:
{
return m_fanout_sender;
}
}
}
</code>
.
and the routine that sends the message use
<code>
sender_reference_type sender = qpid_context->get_sender(destination);
qpid::messaging::Message message(reinterpret_cast<const char *>(message_to_send.ptr()), message_to_send.size());
if (destination.type() != destination_type::broadcast)
{
message.setSubject(destination.name());
}
sender.send(message, qpid_context->m_send_messages_sync);
</code>
On Thu, Jan 26, 2012 at 15:50, Davide Anastasia < Davide.Anastasia@qualitycapital.com> wrote:
> Thanks Gordon,
> I end up setting the routing key in the createSender( ) and
> createReceiver( ) function: is this a common solution? How expensive
> is to create a new Sender for every new message?
>
> Last question: should I be using Runnable and Thread to implement what
> in the old API was performed by the MessageListener? Is there anything
> similar to the class SubscriptionManager in the new API?
>
> Best regards,
> Davide
>
> -----Original Message-----
> From: Gordon Sim [mailto:gsim@redhat.com]
> Sent: 26 January 2012 14:08
> To: users@qpid.apache.org
> Subject: Re: Differences between Message classes in Qpid C++ API
>
> On 01/26/2012 02:06 PM, Davide Anastasia wrote:
> > Hi Andy,
> > Thanks for the quick reply: it did help. In fact I made my code
> > compile, but unfortunately I can't find a way to set the routing_key
> > using the new API. What's the quickest way?
>
> Set the subject. Provided you send to a named exchange, that will then
> be taken as the routing key to use. You can also specify the default
> subject for the sender in the address e.g. my-exchange/my-key.
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project: http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org
>
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project: http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org
>
>
Re: Differences between Message classes in Qpid C++ API
Posted by Virgilio Fornazin <vi...@gmail.com>.
Davide
It´s very CPU and resource intensive. We use RedHat MRG (qpid 0.10) here,
and we ended-up creating specific receivers for each exchange type,
and using specific receiver for specific exchange in our middleware
abstraction code in this way...
<code>
qpid_context->m_direct_sender =
qpid_context->m_session.createSender("amq.direct");
qpid_context->m_topic_sender =
qpid_context->m_session.createSender("amq.topic");
qpid_context->m_fanout_sender =
qpid_context->m_session.createSender("amq.fanout");
</code>
when we need to send a message to a direct key, we use the code
<code>
sender_reference_type get_sender(const destination &
destination)
{
check_connection_state();
switch (destination.type())
{
case destination_type::queue:
{
return m_direct_sender;
}
case destination_type::topic:
{
return m_topic_sender;
}
case destination_type::broadcast:
{
return m_fanout_sender;
}
}
}
</code>
.
and the routine that sends the message use
<code>
sender_reference_type sender =
qpid_context->get_sender(destination);
qpid::messaging::Message message(reinterpret_cast<const
char *>(message_to_send.ptr()), message_to_send.size());
if (destination.type() != destination_type::broadcast)
{
message.setSubject(destination.name());
}
sender.send(message, qpid_context->m_send_messages_sync);
</code>
On Thu, Jan 26, 2012 at 15:50, Davide Anastasia <
Davide.Anastasia@qualitycapital.com> wrote:
> Thanks Gordon,
> I end up setting the routing key in the createSender( ) and
> createReceiver( ) function: is this a common solution? How expensive is
> to create a new Sender for every new message?
>
> Last question: should I be using Runnable and Thread to implement what
> in the old API was performed by the MessageListener? Is there anything
> similar to the class SubscriptionManager in the new API?
>
> Best regards,
> Davide
>
> -----Original Message-----
> From: Gordon Sim [mailto:gsim@redhat.com]
> Sent: 26 January 2012 14:08
> To: users@qpid.apache.org
> Subject: Re: Differences between Message classes in Qpid C++ API
>
> On 01/26/2012 02:06 PM, Davide Anastasia wrote:
> > Hi Andy,
> > Thanks for the quick reply: it did help. In fact I made my code
> > compile, but unfortunately I can't find a way to set the routing_key
> > using the new API. What's the quickest way?
>
> Set the subject. Provided you send to a named exchange, that will then
> be taken as the routing key to use. You can also specify the default
> subject for the sender in the address e.g. my-exchange/my-key.
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project: http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org
>
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project: http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org
>
>
RE: Differences between Message classes in Qpid C++ API
Posted by Davide Anastasia <Da...@qualitycapital.com>.
Thanks Gordon,
I end up setting the routing key in the createSender( ) and
createReceiver( ) function: is this a common solution? How expensive is
to create a new Sender for every new message?
Last question: should I be using Runnable and Thread to implement what
in the old API was performed by the MessageListener? Is there anything
similar to the class SubscriptionManager in the new API?
Best regards,
Davide
-----Original Message-----
From: Gordon Sim [mailto:gsim@redhat.com]
Sent: 26 January 2012 14:08
To: users@qpid.apache.org
Subject: Re: Differences between Message classes in Qpid C++ API
On 01/26/2012 02:06 PM, Davide Anastasia wrote:
> Hi Andy,
> Thanks for the quick reply: it did help. In fact I made my code
> compile, but unfortunately I can't find a way to set the routing_key
> using the new API. What's the quickest way?
Set the subject. Provided you send to a named exchange, that will then
be taken as the routing key to use. You can also specify the default
subject for the sender in the address e.g. my-exchange/my-key.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Re: Differences between Message classes in Qpid C++ API
Posted by Gordon Sim <gs...@redhat.com>.
On 01/26/2012 02:06 PM, Davide Anastasia wrote:
> Hi Andy,
> Thanks for the quick reply: it did help. In fact I made my code compile,
> but unfortunately I can't find a way to set the routing_key using the
> new API. What's the quickest way?
Set the subject. Provided you send to a named exchange, that will then
be taken as the routing key to use. You can also specify the default
subject for the sender in the address e.g. my-exchange/my-key.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
RE: Differences between Message classes in Qpid C++ API
Posted by Davide Anastasia <Da...@qualitycapital.com>.
Hi Andy,
Thanks for the quick reply: it did help. In fact I made my code compile,
but unfortunately I can't find a way to set the routing_key using the
new API. What's the quickest way?
Best,
Davide
-----Original Message-----
From: Andy Goldstein [mailto:agoldste@redhat.com]
Sent: 26 January 2012 12:44
To: users@qpid.apache.org
Subject: Re: Differences between Message classes in Qpid C++ API
The qpid::client API is an older API that is more closely tied to the
inner-workings of the AMQP 0-10 protocol.
The qpid::messaging API is newer and is generally recommended as the API
to use for new development effort. It is designed to abstract away from
protocol-specific details. This will allow the API to support newer
versions of the AMQP protocol without needing major modifications going
forward.
Hope this helps,
Andy
On Jan 26, 2012, at 6:10 AM, Davide Anastasia wrote:
> Hi,
>
> Can anybody explain me what the difference between
> qpid::messaging::Message and qpid::client::Message is?
>
> I am trying to use VariantMap into the pub/sub example, but encode( )
> is only supported for qpid::messaging::Message.
>
>
>
> Best,
>
>
>
> Davide Anastasia
> Analyst, Research & Development
>
>
> Quality Capital Management Ltd.
> QCM House * Horizon Business Village
> No. 1 Brooklands Road
> Weybridge * Surrey KT13 0TJ
> United Kingdom
>
> Tel: +44 (0) 1932 334 400
> Fax: +44 (0) 1932 334 415
> Email: Davide.Anastasia@QualityCapital.com
> <ma...@QualityCapital.com>
>
> www.qualitycapital.com <http://www.qualitycapital.com/>
>
> ________________________________
>
> This email and any attachments are confidential and intended solely
> for the use of the individual(s) to whom it is addressed.
>
> Any views or opinions presented are solely those of the author and do
> not necessarily represent those of Quality Capital Management Ltd. If
> you are not the intended recipient, be advised that you have received
> this email in error and that any use, dissemination, printing,
> forwarding or copying of this email is strictly prohibited. Please
> contact the sender if you have received this email in error. You
> should also be aware that emails are susceptible to interference and
> you should not assume that the contents of this email originated from
> the sender above or that they have been accurately reproduced in their
> original form. Quality Capital Management Ltd is authorised and
> regulated by the Financial Services Authority in the UK and is a
> member of the National Futures Association in the US.
>
> ________________________________
>
>
>
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Re: Differences between Message classes in Qpid C++ API
Posted by Andy Goldstein <ag...@redhat.com>.
The qpid::client API is an older API that is more closely tied to the inner-workings of the AMQP 0-10 protocol.
The qpid::messaging API is newer and is generally recommended as the API to use for new development effort. It is designed to abstract away from protocol-specific details. This will allow the API to support newer versions of the AMQP protocol without needing major modifications going forward.
Hope this helps,
Andy
On Jan 26, 2012, at 6:10 AM, Davide Anastasia wrote:
> Hi,
>
> Can anybody explain me what the difference between
> qpid::messaging::Message and qpid::client::Message is?
>
> I am trying to use VariantMap into the pub/sub example, but encode( ) is
> only supported for qpid::messaging::Message.
>
>
>
> Best,
>
>
>
> Davide Anastasia
> Analyst, Research & Development
>
>
> Quality Capital Management Ltd.
> QCM House * Horizon Business Village
> No. 1 Brooklands Road
> Weybridge * Surrey KT13 0TJ
> United Kingdom
>
> Tel: +44 (0) 1932 334 400
> Fax: +44 (0) 1932 334 415
> Email: Davide.Anastasia@QualityCapital.com
> <ma...@QualityCapital.com>
>
> www.qualitycapital.com <http://www.qualitycapital.com/>
>
> ________________________________
>
> This email and any attachments are confidential and intended solely for
> the use of the individual(s) to whom it is addressed.
>
> Any views or opinions presented are solely those of the author and do
> not necessarily represent those of Quality Capital Management Ltd. If
> you are not the intended recipient, be advised that you have received
> this email in error and that any use, dissemination, printing,
> forwarding or copying of this email is strictly prohibited. Please
> contact the sender if you have received this email in error. You should
> also be aware that emails are susceptible to interference and you should
> not assume that the contents of this email originated from the sender
> above or that they have been accurately reproduced in their original
> form. Quality Capital Management Ltd is authorised and regulated by the
> Financial Services Authority in the UK and is a member of the National
> Futures Association in the US.
>
> ________________________________
>
>
>
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org