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 10:52:16 UTC

Address of default no-name exchange

Hi

I'm trying to use the Qpid C++ client v0.7 to create a Sender pointing  
to the AMQP default (no-name) exchange.

When I try this, I get an error saying "Name cannot be null", no  
matter if I set the Address name to an empty string or not set it at  
all.

How can I point a Sender to this exchange? (I don't want a Sender  
pointing to a queue)

Cheers
Jiri


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Address of default no-name exchange

Posted by Gordon Sim <gs...@redhat.com>.
On 07/03/2011 08:22 AM, Jiri Krutil wrote:
>>> Let's say I'm writing a service processing requests coming from
>>> different clients, each request having a different reply-to address. To
>>> be able to send the responses, do I have to create a new Sender for each
>>> request? If creating a Sender means a sync roundtrip to broker, won't
>>> this kill my performance? Surely there must be some way how to send the
>>> requests async? (without explicit bindings to the response queues)
>>
>> Yes, I agree that in that use case it would be useful to bypass the
>> passive declare. Perhaps an overloaded createSender() with an explicit
>> sync flag?
>>
>> Having a pseudonym for the default exchange might also address your
>> original aim to create a sender to that exchange. My concern there is
>> whether that would be relevant outside the specific protocol
>> version(s) defining such an exchange.
>>
>> I think the fully async creation of senders is a nicer solution.
>> Thoughts?
>
> I think both would be useful.
>
> In some scenarios the list of exchanges is statis and people tend to
> manually pre-configure durable exchanges and don't declare anything
> programmaticaly on run time. In such case you would prefer an async
> version of createSender() that does not check if the exchange is there.

Even if the exchange is pre-configured, verifying that the address used 
to create the sender matches an existing configuration can be useful and 
helps catch setup errors early.

However, I agree that there are cases where you may want to go 
asynchronous (as in your example).

> Being able to address the default exchange would be great. Unless there
> is some strong technical reason against it, I think it should be
> possible. It is the typical thing you want in a request-response
> messaging pattern, where you do *not* want to verify if the reply-to
> queue exists or not.

I think in the general request-response case you want to allow for any 
address, including those that involve another exchange. So to me, using 
a sender to the default exchange is a special case.

> What if you just allowed the Address name to be empty and let it
> represent the default exchange?

I prefer something a little more explicit, e.g. a special name 
(qpid.all-queues). An empty name would look too much like a syntax error 
and is also too closely tied to a detail of a particular protocol version.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Address of default no-name exchange

Posted by Jiri Krutil <ji...@krutil.com>.
>> Let's say I'm writing a service processing requests coming from
>> different clients, each request having a different reply-to address. To
>> be able to send the responses, do I have to create a new Sender for each
>> request? If creating a Sender means a sync roundtrip to broker, won't
>> this kill my performance? Surely there must be some way how to send the
>> requests async? (without explicit bindings to the response queues)
>
> Yes, I agree that in that use case it would be useful to bypass the  
> passive declare. Perhaps an overloaded createSender() with an  
> explicit sync flag?
>
> Having a pseudonym for the default exchange might also address your  
> original aim to create a sender to that exchange. My concern there  
> is whether that would be relevant outside the specific protocol  
> version(s) defining such an exchange.
>
> I think the fully async creation of senders is a nicer solution. Thoughts?

I think both would be useful.

In some scenarios the list of exchanges is statis and people tend to  
manually pre-configure durable exchanges and don't declare anything  
programmaticaly on run time. In such case you would prefer an async  
version of createSender() that does not check if the exchange is there.

Being able to address the default exchange would be great. Unless  
there is some strong technical reason against it, I think it should be  
possible. It is the typical thing you want in a request-response  
messaging pattern, where you do *not* want to verify if the reply-to  
queue exists or not.

What if you just allowed the Address name to be empty and let it  
represent the default exchange?


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Address of default no-name exchange

Posted by Gordon Sim <gs...@redhat.com>.
On 06/30/2011 05:38 AM, Jiri Krutil wrote:
>
>>>> The assumption there is that senders are expensive to create?
>>>
>>> Yes. Are they? (I always specify the node type, so hopefully no need for
>>> a broker roundtrip)
>>
>> No, I don't think they are. Especially as you are specifying the node
>> type to avoid having to look that up. It will do a synchronous,
>> passive queue declare at present. The reason for that is simply to
>> ensure the address is valid before you start sending. I could imagine
>> having some way to disable that or make it async if it proves a problem.
>
> Let's say I'm writing a service processing requests coming from
> different clients, each request having a different reply-to address. To
> be able to send the responses, do I have to create a new Sender for each
> request? If creating a Sender means a sync roundtrip to broker, won't
> this kill my performance? Surely there must be some way how to send the
> requests async? (without explicit bindings to the response queues)

Yes, I agree that in that use case it would be useful to bypass the 
passive declare. Perhaps an overloaded createSender() with an explicit 
sync flag?

Having a pseudonym for the default exchange might also address your 
original aim to create a sender to that exchange. My concern there is 
whether that would be relevant outside the specific protocol version(s) 
defining such an exchange.

I think the fully async creation of senders is a nicer solution. Thoughts?

>>>> The reply-to address doesn't have to be a queue of course, to be
>>>> completely generic it should handle any exchange/routing-key pair (at
>>>> least in AMQP 0-10).
>>>
>>> OK, didn't know that. I wanted to check if this is also the case for
>>> AMQP 0-9-1, but could not find that info in the specs. Do you know?
>>
>> Prior to 0-10 it was documented as 'the destination to reply to' which
>> would imply it should contain an exchange name. Obviously this was not
>> precise enough for many cases which is why it was refined a little for
>> 0-10.
>
> Can you please explain what happens if I create a response queue and use
> its address as the parameter of Message::setReplyTo()? According to the
> specs, reply-to attribute is a combination of exchange name and routing
> key. How does my queue address translate to this? Does it use the
> default exchange, which I can't otherwise address?

Yes.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Address of default no-name exchange

Posted by Jiri Krutil <ji...@krutil.com>.
>>> The assumption there is that senders are expensive to create?
>>
>> Yes. Are they? (I always specify the node type, so hopefully no need for
>> a broker roundtrip)
>
> No, I don't think they are. Especially as you are specifying the node 
> type to avoid having to look that up. It will do a synchronous, 
> passive queue declare at present. The reason for that is simply to 
> ensure the address is valid before you start sending. I could imagine 
> having some way to disable that or make it async if it proves a problem.

Let's say I'm writing a service processing requests coming from 
different clients, each request having a different reply-to address. To 
be able to send the responses, do I have to create a new Sender for each 
request? If creating a Sender means a sync roundtrip to broker, won't 
this kill my performance? Surely there must be some way how to send the 
requests async? (without explicit bindings to the response queues)

>>> The reply-to address doesn't have to be a queue of course, to be
>>> completely generic it should handle any exchange/routing-key pair (at
>>> least in AMQP 0-10).
>>
>> OK, didn't know that. I wanted to check if this is also the case for
>> AMQP 0-9-1, but could not find that info in the specs. Do you know?
>
> Prior to 0-10 it was documented as 'the destination to reply to' which 
> would imply it should contain an exchange name. Obviously this was not 
> precise enough for many cases which is why it was refined a little for 
> 0-10.

Can you please explain what happens if I create a response queue and use 
its address as the parameter of Message::setReplyTo()? According to the 
specs, reply-to attribute is a combination of exchange name and routing 
key. How does my queue address translate to this? Does it use the 
default exchange, which I can't otherwise address?

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Address of default no-name exchange

Posted by Gordon Sim <gs...@redhat.com>.
On 06/29/2011 12:55 PM, Jiri Krutil wrote:
>> The assumption there is that senders are expensive to create?
>
> Yes. Are they? (I always specify the node type, so hopefully no need for
> a broker roundtrip)

No, I don't think they are. Especially as you are specifying the node 
type to avoid having to look that up. It will do a synchronous, passive 
queue declare at present. The reason for that is simply to ensure the 
address is valid before you start sending. I could imagine having some 
way to disable that or make it async if it proves a problem.

>> The reply-to address doesn't have to be a queue of course, to be
>> completely generic it should handle any exchange/routing-key pair (at
>> least in AMQP 0-10).
>
> OK, didn't know that. I wanted to check if this is also the case for
> AMQP 0-9-1, but could not find that info in the specs. Do you know?

Prior to 0-10 it was documented as 'the destination to reply to' which 
would imply it should contain an exchange name. Obviously this was not 
precise enough for many cases which is why it was refined a little for 0-10.

> Which Address attributes are relevant for the parameter of
> Message::setReplyTo() - name, type, subject?

Yes, those are the three attributes that are relevant.

>>> Let's say I create a Sender for queue A. It will actually point to the
>>> default exchange with the routing key defaulting to A, right?
>>
>> No, the messaging library resolves an address to a particular broker
>> entity. If the name matches a queue, then it assumes you want to send
>> to the queue. If the name matches an exchange then it assumes you want
>> to send to the exchange.
>
> OK, coming back to the original question: is there a way how to create a
> Sender pointing to the default exchange?

No. The messaging API doesn't treat the default exchange as an 
addressable node in its own right.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Address of default no-name exchange

Posted by Jiri Krutil <ji...@krutil.com>.
> The assumption there is that senders are expensive to create?

Yes. Are they? (I always specify the node type, so hopefully no need  
for a broker roundtrip)

> The reply-to address doesn't have to be a queue of course, to be  
> completely generic it should handle any exchange/routing-key pair  
> (at least in AMQP 0-10).

OK, didn't know that. I wanted to check if this is also the case for  
AMQP 0-9-1, but could not find that info in the specs. Do you know?

Which Address attributes are relevant for the parameter of  
Message::setReplyTo() - name, type, subject?

>> Let's say I create a Sender for queue A. It will actually point to the
>> default exchange with the routing key defaulting to A, right?
>
> No, the messaging library resolves an address to a particular broker  
> entity. If the name matches a queue, then it assumes you want to  
> send to the queue. If the name matches an exchange then it assumes  
> you want to send to the exchange.

OK, coming back to the original question: is there a way how to create  
a Sender pointing to the default exchange?


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Address of default no-name exchange

Posted by Gordon Sim <gs...@redhat.com>.
On 06/29/2011 10:38 AM, Jiri Krutil wrote:
>> The default exchange is a direct exchange and the bindings are forced
>> to match exactly with the existing queue names. It is a workaround for
>> the fact that AMQP forces you to send to an exchange whether you want
>> to or not.
>>
>> What is it you actually want to achieve? The only thing you can do by
>> sending messages to the default exchange is send them to a queue (or
>> have them dropped).
>
> A Sender for the default exchange may be useful in case you want to send
> to many different queues using one Sender and a different routing key
> for each message. For instance when sending responses to reply-to queues
> in a request-response pattern.

Ok, I understand. The assumption there is that senders are expensive to 
create?

The reply-to address doesn't have to be a queue of course, to be 
completely generic it should handle any exchange/routing-key pair (at 
least in AMQP 0-10).

> I'm working on a AMQP vendor-neutral C++ API and I'm trying to stay as
> close to the concepts and ideas of the AMQP specs as possible. I guess
> sending to the default exchange is a completely sane thing to do.

Yes, I can see that point of view.

One of the influences on Qpid's messaging API is the 1.0 specification. 
There, to send a message you establish a link to a node on the broker. 
This link is then used for any flow control and for some reliability 
approaches.

My personal opinion is that the default exchange was a slightly clumsy 
workaround for the fact that the versions of AMQP to date restricted 
message 'sinks' to always be exchanges (and message 'sources' to always 
be queues, though that's not related to the default exchange). The lack 
of an explicit relationship between sender and sink was also an issue 
(makes flow control more difficult for example).

The differences between the AMQP versions are significant. An API that 
covers all of them would almost necessarily have to be at a higher level 
of abstraction. That was the approach we took. We felt that the real 
concern of the API was to control the inflow and outflow of messages and 
all that this encompasses, but not to explicitly expose the mechanisms 
as presented by underlying protocol versions.

I'd love to see your API if and when you are ready to publish it!

> Let's say I create a Sender for queue A. It will actually point to the
> default exchange with the routing key defaulting to A, right?

No, the messaging library resolves an address to a particular broker 
entity. If the name matches a queue, then it assumes you want to send to 
the queue. If the name matches an exchange then it assumes you want to 
send to the exchange. If there is both a queue and an exchange with the 
same name then at present you get an error and you have to explicitly 
choose which one you want by indicating the node type in the address.

> What happens if I use this sender to send a message with subject being
> set to B? Will the message go to queue B?

No, it won't.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Address of default no-name exchange

Posted by Jiri Krutil <ji...@krutil.com>.
> The default exchange is a direct exchange and the bindings are  
> forced to match exactly with the existing queue names. It is a  
> workaround for the fact that AMQP forces you to send to an exchange  
> whether you want to or not.
>
> What is it you actually want to achieve? The only thing you can do  
> by sending messages to the default exchange is send them to a queue  
> (or have them dropped).

A Sender for the default exchange may be useful in case you want to  
send to many different queues using one Sender and a different routing  
key for each message. For instance when sending responses to reply-to  
queues in a request-response pattern.

I'm working on a AMQP vendor-neutral C++ API and I'm trying to stay as  
close to the concepts and ideas of the AMQP specs as possible. I guess  
sending to the default exchange is a completely sane thing to do.

Let's say I create a Sender for queue A. It will actually point to the  
default exchange with the routing key defaulting to A, right?

What happens if I use this sender to send a message with subject being  
set to B? Will the message go to queue B?

Cheers
Jiri


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Address of default no-name exchange

Posted by Gordon Sim <gs...@redhat.com>.
On 06/29/2011 09:52 AM, Jiri Krutil wrote:
> Hi
>
> I'm trying to use the Qpid C++ client v0.7 to create a Sender pointing
> to the AMQP default (no-name) exchange.
>
> When I try this, I get an error saying "Name cannot be null", no matter
> if I set the Address name to an empty string or not set it at all.
>
> How can I point a Sender to this exchange? (I don't want a Sender
> pointing to a queue)

The default exchange is a direct exchange and the bindings are forced to 
match exactly with the existing queue names. It is a workaround for the 
fact that AMQP forces you to send to an exchange whether you want to or not.

What is it you actually want to achieve? The only thing you can do by 
sending messages to the default exchange is send them to a queue (or 
have them dropped).

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org