You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Siamak Kolahi <si...@gmail.com> on 2010/04/05 22:22:57 UTC

Multiple Headers with the same key

Hi guys,

I have got a problem with the Headers exchange. The problem is that I want
to subscribe to multiple headers in a headers exchange, with same key and
different values per say, and receive messages for all messages matching ANY
of those values. say I want to subscribe to a channel and receive all
messages with headers named 'foo' with either values of a or b. would such
subscription be possible in qpid? or I need to handle this complexity at own
end?

I can understand why such logic wont make sense for ALL case because the
header should match one of them anyway. But for the ANY case, it would
improve the performance and complexity for me if I would be able to do so.
So I was wondering if this is by design?

I know in Python client per say, arguments are passed to exchange using a
dictionary, eliminating such flexibility right off the bet (no multiple
entries with same key in Python dicts). Also as I see in C++ broker, headers
are handled using a mapping dictionary, again removing such possibility.

So is there any thoughts on such scenario? is it by design or by spec
resulted in such implementation? (cant find anything in AMQP spec regarding
that)

Thanks,
Siamak

Re: Multiple Headers with the same key

Posted by Gordon Sim <gs...@redhat.com>.
On 04/07/2010 03:45 PM, Siamak Kolahi wrote:
> I tried doing so (binding same channel multiple times with different
> values). but it doesnt work out. It only receives messages matching the last
> value binded to.

Are you using a different binding key in each case?

> Thanks,
> Siamak
>
> On Tue, Apr 6, 2010 at 11:55 AM, Gordon Sim<gs...@redhat.com>  wrote:
>
>> On 04/05/2010 09:22 PM, Siamak Kolahi wrote:
>>
>>> Hi guys,
>>>
>>> I have got a problem with the Headers exchange. The problem is that I want
>>> to subscribe to multiple headers in a headers exchange, with same key and
>>> different values per say, and receive messages for all messages matching
>>> ANY
>>> of those values. say I want to subscribe to a channel and receive all
>>> messages with headers named 'foo' with either values of a or b. would such
>>> subscription be possible in qpid? or I need to handle this complexity at
>>> own
>>> end?
>>>
>>
>> One simple way is simply to bind your subscription queue multiple times,
>> once for each valid value. You should then get any message that matches at
>> least one of those bindings.
>>
>>
>>   I can understand why such logic wont make sense for ALL case because the
>>> header should match one of them anyway. But for the ANY case, it would
>>> improve the performance and complexity for me if I would be able to do so.
>>> So I was wondering if this is by design?
>>>
>>> I know in Python client per say, arguments are passed to exchange using a
>>> dictionary, eliminating such flexibility right off the bet (no multiple
>>> entries with same key in Python dicts). Also as I see in C++ broker,
>>> headers
>>> are handled using a mapping dictionary, again removing such possibility.
>>>
>>> So is there any thoughts on such scenario? is it by design or by spec
>>> resulted in such implementation? (cant find anything in AMQP spec
>>> regarding
>>> that)
>>>
>>
>> As far as I recall the spec states that maps with duplicate keys are not
>> valid and lead to unpredictable behaviour. In qpid I believe none of the
>> clients or brokers will send such maps/field-tables.
>>
>>
>> ---------------------------------------------------------------------
>> 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: Multiple Headers with the same key

Posted by Siamak Kolahi <si...@gmail.com>.
I tried doing so (binding same channel multiple times with different
values). but it doesnt work out. It only receives messages matching the last
value binded to.

Thanks,
Siamak

On Tue, Apr 6, 2010 at 11:55 AM, Gordon Sim <gs...@redhat.com> wrote:

> On 04/05/2010 09:22 PM, Siamak Kolahi wrote:
>
>> Hi guys,
>>
>> I have got a problem with the Headers exchange. The problem is that I want
>> to subscribe to multiple headers in a headers exchange, with same key and
>> different values per say, and receive messages for all messages matching
>> ANY
>> of those values. say I want to subscribe to a channel and receive all
>> messages with headers named 'foo' with either values of a or b. would such
>> subscription be possible in qpid? or I need to handle this complexity at
>> own
>> end?
>>
>
> One simple way is simply to bind your subscription queue multiple times,
> once for each valid value. You should then get any message that matches at
> least one of those bindings.
>
>
>  I can understand why such logic wont make sense for ALL case because the
>> header should match one of them anyway. But for the ANY case, it would
>> improve the performance and complexity for me if I would be able to do so.
>> So I was wondering if this is by design?
>>
>> I know in Python client per say, arguments are passed to exchange using a
>> dictionary, eliminating such flexibility right off the bet (no multiple
>> entries with same key in Python dicts). Also as I see in C++ broker,
>> headers
>> are handled using a mapping dictionary, again removing such possibility.
>>
>> So is there any thoughts on such scenario? is it by design or by spec
>> resulted in such implementation? (cant find anything in AMQP spec
>> regarding
>> that)
>>
>
> As far as I recall the spec states that maps with duplicate keys are not
> valid and lead to unpredictable behaviour. In qpid I believe none of the
> clients or brokers will send such maps/field-tables.
>
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org
>
>

Re: Multiple Headers with the same key

Posted by Gordon Sim <gs...@redhat.com>.
On 04/05/2010 09:22 PM, Siamak Kolahi wrote:
> Hi guys,
>
> I have got a problem with the Headers exchange. The problem is that I want
> to subscribe to multiple headers in a headers exchange, with same key and
> different values per say, and receive messages for all messages matching ANY
> of those values. say I want to subscribe to a channel and receive all
> messages with headers named 'foo' with either values of a or b. would such
> subscription be possible in qpid? or I need to handle this complexity at own
> end?

One simple way is simply to bind your subscription queue multiple times, 
once for each valid value. You should then get any message that matches 
at least one of those bindings.

> I can understand why such logic wont make sense for ALL case because the
> header should match one of them anyway. But for the ANY case, it would
> improve the performance and complexity for me if I would be able to do so.
> So I was wondering if this is by design?
>
> I know in Python client per say, arguments are passed to exchange using a
> dictionary, eliminating such flexibility right off the bet (no multiple
> entries with same key in Python dicts). Also as I see in C++ broker, headers
> are handled using a mapping dictionary, again removing such possibility.
>
> So is there any thoughts on such scenario? is it by design or by spec
> resulted in such implementation? (cant find anything in AMQP spec regarding
> that)

As far as I recall the spec states that maps with duplicate keys are not 
valid and lead to unpredictable behaviour. In qpid I believe none of the 
clients or brokers will send such maps/field-tables.

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