C++ Messaging API: getReceiver(topic/subject)

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

C++ Messaging API: getReceiver(topic/subject)

mottese
Hi, I'm trying to use getReceiver, but am not getting the results I'm expecting. For example, this is what I'm doing:

  Session session = con.getSession();
  Address addr("amq.topic/mySubject");
  session.createReceiver(addr);
  ...
  ...
  Receiver r = session.getReceiver("amq.topic/mySubject");

This is throwing a KeyError and I can't figure out why. Any help would be appreciated.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: C++ Messaging API: getReceiver(topic/subject)

Chris Richardson
I think you might mean to use createReceiver (to create a new
receiver), not getReceiver (to get an existing one). Note the
documentation for the getReceiver call specifies "@exception KeyError
if there is none for that name."

HTH

Chris

On 1 June 2017 at 16:13, mottese <[hidden email]> wrote:

> Hi, I'm trying to use getReceiver, but am not getting the results I'm
> expecting. For example, this is what I'm doing:
>
>   Session session = con.getSession();
>   Address addr("amq.topic/mySubject");
>   session.createReceiver(addr);
>   ...
>   ...
>   Receiver r = session.getReceiver("amq.topic/mySubject");
>
> This is throwing a KeyError and I can't figure out why. Any help would be
> appreciated.
>
>
>
>
> --
> View this message in context: http://qpid.2158936.n2.nabble.com/C-Messaging-API-getReceiver-topic-subject-tp7663715.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>



--
Chris Richardson, System Architect
[hidden email]

FourC AS, Vestre Rosten 81, Trekanten, NO-7075 Tiller, Norway
www.fourc.eu

Follow us on LinkedIn, Facebook, Google+ and Twitter!

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: C++ Messaging API: getReceiver(topic/subject)

mottese
This post was updated on .
Chris Richardson wrote
I think you might mean to use createReceiver (to create a new
receiver), not getReceiver (to get an existing one). Note the
documentation for the getReceiver call specifies "@exception KeyError
if there is none for that name."
Apologies, my question was a little unclear. I'm creating a receiver with the given address and then later in my code I'm trying to get that same receiver so that I can manually close it. I could keep track of it by doing this:

  Receiver r = session.createReceiver(addr);
  ...
  ...
  r.close();

I was just trying to avoid that because

1) The "..." in my code is a lot of separation. The creation of a receiver and the deletion of it is actually in totally different functions.

2) If my Session is already keeping track of all of its Receivers, manually keeping track of Receivers seems redundant.

If that is still unclear, I can post a code example to make it more clear what I'm trying to do.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: C++ Messaging API: getReceiver(topic/subject)

Gordon Sim
In reply to this post by mottese
On 01/06/17 16:13, mottese wrote:

> Hi, I'm trying to use getReceiver, but am not getting the results I'm
> expecting. For example, this is what I'm doing:
>
>   Session session = con.getSession();
>   Address addr("amq.topic/mySubject");
>   session.createReceiver(addr);
>   ...
>   ...
>   Receiver r = session.getReceiver("amq.topic/mySubject");
>
> This is throwing a KeyError and I can't figure out why. Any help would be
> appreciated.

You need to use the receivers 'name' to retrieve it via the
getReceiver() call. The name for the receiver is based on the 'name' of
the thing in the address - aka the 'node', which in your case is
amq.topic (the mySubject part is the subject).

If you have only one receiver on the session for a given node
(exchange/queue) then the receiver name will match that. If not, the
receiver name is qualified with a unique counter, e.g. amq.topic_1,
amq.topic_2 etc.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: C++ Messaging API: getReceiver(topic/subject)

Gordon Sim
On 01/06/17 17:58, Gordon Sim wrote:

> On 01/06/17 16:13, mottese wrote:
>> Hi, I'm trying to use getReceiver, but am not getting the results I'm
>> expecting. For example, this is what I'm doing:
>>
>>   Session session = con.getSession();
>>   Address addr("amq.topic/mySubject");
>>   session.createReceiver(addr);
>>   ...
>>   ...
>>   Receiver r = session.getReceiver("amq.topic/mySubject");
>>
>> This is throwing a KeyError and I can't figure out why. Any help would be
>> appreciated.
>
> You need to use the receivers 'name' to retrieve it via the
> getReceiver() call. The name for the receiver is based on the 'name' of
> the thing in the address - aka the 'node', which in your case is
> amq.topic (the mySubject part is the subject).
>
> If you have only one receiver on the session for a given node
> (exchange/queue) then the receiver name will match that. If not, the
> receiver name is qualified with a unique counter, e.g. amq.topic_1,
> amq.topic_2 etc.

Actually, I need to qualify this a little. The above is accurate for
AMQP 0-10. For AMQP 1.0 it is similar but slightly different. The name
of the receiver is the name of the underlying AMQP 1.0 link. You can
specify this explicitly in the address (e.g. 'amq.topic/mySubject;
{link:{name:myname}}'. If you don't specify it explicitly it will be
generated for you as the node name (e.g. amq.topic) plus a UUID.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: C++ Messaging API: getReceiver(topic/subject)

mottese
Gordon Sim wrote
Actually, I need to qualify this a little. The above is accurate for
AMQP 0-10. For AMQP 1.0 it is similar but slightly different. The name
of the receiver is the name of the underlying AMQP 1.0 link. You can
specify this explicitly in the address (e.g. 'amq.topic/mySubject;
{link:{name:myname}}'. If you don't specify it explicitly it will be
generated for you as the node name (e.g. amq.topic) plus a UUID.
Thanks for the answer. That's exactly what I was looking for. I will make sure to specify my own link names.
Loading...