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 <
[email protected]> 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:[email protected]]
> Sent: 26 January 2012 14:08
> To: [email protected]
> 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:[email protected]
>
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project: http://qpid.apache.org
> Use/Interact: mailto:[email protected]
>
>