You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Jason Pellerin <jp...@leapfrogonline.com> on 2009/12/09 22:25:58 UTC

python client new api: declaring and binding

I'd like to try out the new api (qpid.messaging) but I'm hung up on declaring
and binding queues and exchanges. There doesn't seem to be a way, as far as I
can tell, to do the equivalent of:

session.queue_declare(queue=queue, ...)
session.exchange_declare(exchange=exchange,
                                        type=exchange_type,
                                        ...)
session.exchange_bind(queue=queue, exchange=exchange,
                                    routing_key=routing_key)

I've tried various arguments to messaging.Connection().session().receiver()
but as far as I can tell from the target address parsing and option use in
qpid.driver, there's no way to say "I want to receive on queue Q on exchange E
(and here's my routing key)."

I see that qpid.brokertest is working around this by opening two connections,
but that's not a very appealing solution, at least for my web-app-centric
world.

Am I missing something?

Thanks,

Jason Pellerin

CONFIDENTIALITY NOTE
The document(s) accompanying this e-mail transmission, if any, and the e-mail transmittal message containing information from Leapfrog Online Customer Acquisition, LLC is confidential or privileged. The information is intended to be for the use of the individual(s) or entity(ies) named on this e-mail transmission message. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this e-mail is prohibited. If you have received this e-mail in error, please immediately delete this e-mail and notify us by telephone of the error.

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


Re: python client new api: declaring and binding

Posted by Rafael Schloming <ra...@redhat.com>.

Jason Pellerin wrote:
> And on a more high level, I'm wondering why the receiver/sender target
> specification works by parsing arguments and pseudo-dicts out of a string
> instead of something like:
> 
> r = session.receiver(exchange=e, routing_key=k, create='always')
> 
> ...which to me at least is more clear.

We've chosen to define the source/target specifications as strings 
because we'd like the syntax and semantics to be compatible across 
clients in the different languages, i.e. we'd like you to be able to cut 
and paste the same source/target specification between C++, Java, and 
Python clients and get identical results.

We also want to make it easy to put these specifications into config 
files or grab them from the command line rather than hard coding them.

--Rafael

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


Re: python client new api: declaring and binding

Posted by Gordon Sim <gs...@redhat.com>.
On 12/11/2009 04:03 PM, Jason Pellerin wrote:
> On Friday 11 December 2009 06:52:05 Gordon Sim wrote:
>> On 12/09/2009 09:25 PM, Jason Pellerin wrote:
>>> I'd like to try out the new api (qpid.messaging) but I'm hung up on
>>> declaring and binding queues and exchanges. There doesn't seem to be a
>>> way, as far as I can tell, to do the equivalent of:
>>>
>>> session.queue_declare(queue=queue, ...)
>>> session.exchange_declare(exchange=exchange,
>>>                                           type=exchange_type,
>>>                                           ...)
>>> session.exchange_bind(queue=queue, exchange=exchange,
>>>                                       routing_key=routing_key)
>
>> If you want to create the exchange if it doesn't exist you can use
>> 'my-exchange/my-routing-key; {create: always}'.
>
> I think I asked my question poorly, sorry. I see how to make a receiver create
> an exchange, but I don't see how to set the exchange type when doing that.

Sorry, that should have been (for e.g. a direct exchange):

'my-exchange/my-routing-key; {create: always, 
node-properties:{type:topic, x-properties: {type: direct}} }'

> And on a more high level, I'm wondering why the receiver/sender target
> specification works by parsing arguments and pseudo-dicts out of a string
> instead of something like:
>
> r = session.receiver(exchange=e, routing_key=k, create='always')
>
> ...which to me at least is more clear.
>
>   Thanks,
>
> JP
>
> CONFIDENTIALITY NOTE
> The document(s) accompanying this e-mail transmission, if any, and the e-mail transmittal message containing information from Leapfrog Online Customer Acquisition, LLC is confidential or privileged. The information is intended to be for the use of the individual(s) or entity(ies) named on this e-mail transmission message. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this e-mail is prohibited. If you have received this e-mail in error, please immediately delete this e-mail and notify us by telephone of the error.
>
> ---------------------------------------------------------------------
> 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: python client new api: declaring and binding

Posted by Jason Pellerin <jp...@leapfrogonline.com>.
On Friday 11 December 2009 06:52:05 Gordon Sim wrote:
> On 12/09/2009 09:25 PM, Jason Pellerin wrote:
> > I'd like to try out the new api (qpid.messaging) but I'm hung up on
> > declaring and binding queues and exchanges. There doesn't seem to be a
> > way, as far as I can tell, to do the equivalent of:
> >
> > session.queue_declare(queue=queue, ...)
> > session.exchange_declare(exchange=exchange,
> >                                          type=exchange_type,
> >                                          ...)
> > session.exchange_bind(queue=queue, exchange=exchange,
> >                                      routing_key=routing_key)

> If you want to create the exchange if it doesn't exist you can use
> 'my-exchange/my-routing-key; {create: always}'.

I think I asked my question poorly, sorry. I see how to make a receiver create
an exchange, but I don't see how to set the exchange type when doing that.

And on a more high level, I'm wondering why the receiver/sender target
specification works by parsing arguments and pseudo-dicts out of a string
instead of something like:

r = session.receiver(exchange=e, routing_key=k, create='always')

...which to me at least is more clear.

 Thanks,

JP

CONFIDENTIALITY NOTE
The document(s) accompanying this e-mail transmission, if any, and the e-mail transmittal message containing information from Leapfrog Online Customer Acquisition, LLC is confidential or privileged. The information is intended to be for the use of the individual(s) or entity(ies) named on this e-mail transmission message. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this e-mail is prohibited. If you have received this e-mail in error, please immediately delete this e-mail and notify us by telephone of the error.

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


Re: python client new api: declaring and binding

Posted by Gordon Sim <gs...@redhat.com>.
On 12/09/2009 09:25 PM, Jason Pellerin wrote:
> I'd like to try out the new api (qpid.messaging) but I'm hung up on declaring
> and binding queues and exchanges. There doesn't seem to be a way, as far as I
> can tell, to do the equivalent of:
>
> session.queue_declare(queue=queue, ...)
> session.exchange_declare(exchange=exchange,
>                                          type=exchange_type,
>                                          ...)
> session.exchange_bind(queue=queue, exchange=exchange,
>                                      routing_key=routing_key)
>
> I've tried various arguments to messaging.Connection().session().receiver()
> but as far as I can tell from the target address parsing and option use in
> qpid.driver, there's no way to say "I want to receive on queue Q on exchange E
> (and here's my routing key)."

If the exchange already exists then creating a receiver with an address 
of the form my-exchange/my-routing-key will cause messages sent to that 
exchange with a matching routing-key to be delivered to your receiver. A 
subscription queue will be created automatically.

If you want to create the exchange if it doesn't exist you can use 
'my-exchange/my-routing-key; {create: always}'.

>
> I see that qpid.brokertest is working around this by opening two connections,
> but that's not a very appealing solution, at least for my web-app-centric
> world.
>
> Am I missing something?
>
> Thanks,
>
> Jason Pellerin
>
> CONFIDENTIALITY NOTE
> The document(s) accompanying this e-mail transmission, if any, and the e-mail transmittal message containing information from Leapfrog Online Customer Acquisition, LLC is confidential or privileged. The information is intended to be for the use of the individual(s) or entity(ies) named on this e-mail transmission message. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this e-mail is prohibited. If you have received this e-mail in error, please immediately delete this e-mail and notify us by telephone of the error.
>
> ---------------------------------------------------------------------
> 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