You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Jiri Krutil <ji...@krutil.com> on 2011/06/29 11:43:27 UTC
How to use server-named queues in C++ client
Hi
I would like to understand how server-named queues (those with a # in
the name) are to be used properly.
If I want Qpid to expand the # with a UID, I have to declare the queue
with delete:always, correct?
The typical example of use of such a queue is:
Sender sender = session.createSender("service_queue");
Address responseQueue("#response-queue; {create:always, delete:always}");
Receiver receiver = session.createReceiver(responseQueue);
Do I have to use the Address object returned by createSender() to
create the Receiver? I'm trying to use the queue name (as
std::string), but that does not seem to work.
Are these server-named queues exclusive and auto-delete? Who can see
them? When are they delete by the broker?
Cheers
Jiri
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Re: How to use server-named queues in C++ client
Posted by Gordon Sim <gs...@redhat.com>.
On 06/29/2011 01:24 PM, Jiri Krutil wrote:
>>> I have observed that # only seems to be expanded if I use delete:always.
>>> Is that so?
>>
>> No, that should not be the case.
>
> I was wrong, it's something else. It seems that the # gets expanded when
> I construct the Address object using constructor
>
> Address(const std::string &address)
>
> but not when using constructor
>
> Address(const std::string &name, const std::string &subject, const
> qpid::types::Variant::Map &options, const std::string &type="")
>
> Don't know if that's intentional, but certainly I did not find any
> mention about it in the docs.
I'm not sure if it's intentional myself(!)... certainly needs some
documentation one way or another.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Re: How to use server-named queues in C++ client
Posted by Jiri Krutil <ji...@krutil.com>.
>> I have observed that # only seems to be expanded if I use delete:always.
>> Is that so?
>
> No, that should not be the case.
I was wrong, it's something else. It seems that the # gets expanded
when I construct the Address object using constructor
Address(const std::string &address)
but not when using constructor
Address(const std::string &name, const std::string &subject, const
qpid::types::Variant::Map &options, const std::string &type="")
Don't know if that's intentional, but certainly I did not find any
mention about it in the docs.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Re: How to use server-named queues in C++ client
Posted by Gordon Sim <gs...@redhat.com>.
On 06/29/2011 12:06 PM, Jiri Krutil wrote:
> I have observed that # only seems to be expanded if I use delete:always.
> Is that so?
No, that should not be the case.
>> If you set auto-delete, then the queue is deleted by the broker when
>> no longer used as per the rules in AMQP 0-10.
>
> My impression is that I should use auto-delete:True but not
> delete:always.
Yes, at present that is my preference also.
> But then the # won't expand.
It should do. If I change the client example[1] to use auto-delete
rather than delete:always[2], the response queue name is still expanded
to a full UUID. The declare issued is:
{QueueDeclareBody:
queue=ede4138e-b708-4454-b9a6-e5ef195ebda6#response-queue;
alternate-exchange=; passive=1; arguments={}; }
[1]
https://svn.apache.org/repos/asf/qpid/trunk/qpid/cpp/examples/messaging/client.cpp
[2] e.g.
Index: examples/messaging/client.cpp
===================================================================
--- examples/messaging/client.cpp (revision 1139306)
+++ examples/messaging/client.cpp (working copy)
@@ -48,7 +48,7 @@
Sender sender = session.createSender("service_queue");
//create temp queue & receiver...
- Address responseQueue("#response-queue; {create:always,
delete:always}");
+ Address responseQueue("#response-queue; {create:always,
node:{x-declare:{auto-delete:True, exclusive:True}}}");
Receiver receiver = session.createReceiver(responseQueue);
// Now send some messages ...
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Re: How to use server-named queues in C++ client
Posted by Jiri Krutil <ji...@krutil.com>.
>> If I want Qpid to expand the # with a UID, I have to declare the queue
>> with delete:always, correct?
>>
>> The typical example of use of such a queue is:
>>
>> Sender sender = session.createSender("service_queue");
>> Address responseQueue("#response-queue; {create:always, delete:always}");
>> Receiver receiver = session.createReceiver(responseQueue);
>>
>> Do I have to use the Address object returned by createSender() to create
>> the Receiver? I'm trying to use the queue name (as std::string), but
>> that does not seem to work.
>
> Sorry, I don't understand the question. Could you elaborate a little?
My problem was that a UUID-named queue created using a Sender could
not be found by a Receiver. This was because the queue was created
with delete:always and the Sender was already closed.
I have observed that # only seems to be expanded if I use
delete:always. Is that so?
> If you set auto-delete, then the queue is deleted by the broker when
> no longer used as per the rules in AMQP 0-10.
My impression is that I should use auto-delete:True but not
delete:always. But then the # won't expand. Should I generate an UUID
for the queue name myself?
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Re: How to use server-named queues in C++ client
Posted by Gordon Sim <gs...@redhat.com>.
On 06/29/2011 10:43 AM, Jiri Krutil wrote:
> I would like to understand how server-named queues (those with a # in
> the name) are to be used properly.
They aren't actually server named queues (as in early versions of AMQP).
The # is simply a shortcut for creating a unique identifier in the
address string (currently a UUID). That is done client side.
> If I want Qpid to expand the # with a UID, I have to declare the queue
> with delete:always, correct?
>
> The typical example of use of such a queue is:
>
> Sender sender = session.createSender("service_queue");
> Address responseQueue("#response-queue; {create:always, delete:always}");
> Receiver receiver = session.createReceiver(responseQueue);
>
> Do I have to use the Address object returned by createSender() to create
> the Receiver? I'm trying to use the queue name (as std::string), but
> that does not seem to work.
Sorry, I don't understand the question. Could you elaborate a little?
> Are these server-named queues exclusive and auto-delete?
No, not by default, though you can make them so. E.g.
"#response-queue; {create:always, node:{x-declare:{exclusive:True,
auto-delete:True}}}"
Note the the 'x-' style address properties are version specific options
that are primarily there to allow you to control the 0-10 declares etc
if you want to. We hope to refine and expand the more general options also.
> Who can see them?
Anyone can see them (assuming ACL doesn't forbid it) but if they are
exclusive then the usual rules apply (i.e. only the session who first
declared them can use them).
> When are they delete by the broker?
An address with 'delete: always' will have the client delete the queue
when the sender/receiver using the address is closed. That mode at
present does have some issues (if you have multiple senders/receivers
using the queue, the first to close would delete it from under the
others; also if the client dies the queue can get left on the broker).
If you set auto-delete, then the queue is deleted by the broker when no
longer used as per the rules in AMQP 0-10.
I'd like to improve the deletion policy a little here to get something
simple and practical for the general case.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org