You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by reekahdoh <ri...@atosorigin.com> on 2011/07/08 14:09:27 UTC
Dynamic Routes and Duplicate Messages
Hello All,
I'll try and keep this as simple as possible. I'm using C++ Apache Qpid
v0.8, and am having a problem when using dynamic routes with the headers
exchange.
FIRSTLY:
Send two messages the default headers exchange on a broker.
One Message has the headers :data-format=standard, data-source=A
One Message has the headers :data-format=standard, data-source=B
Set up two subscriptions to the same broker.
One subscription (A) listening on for messages where data-format=standard.
One subscription (B) listening on for messages where data-source=B.
EXPECTED RESULTS:
(A) receives contains two messages, where the data-format=standard
(B) receives one message, where the data-source = B
So, if I run the above I get the correct expected results.
HOWEVER ...
Now introduce another broker. Link the two using a dynamic route on the
headers exchange.
Publish messages to BROKER_A and subscribe to messages on BROKER_B.
I would expect the results to be the same as above but now what I see
is:-
ACTUAL RESULTS:
(A) queue contains three messages
(B) queue contains two message
Somehow duplicates are being created when using the dyamic route. Is
this a bug? I certainly would not expect to see this behaviour differ
when using dynamic routes. It seems that the dynamic route picks up on the
same message being delivered to each different subscription. Surely the end
behaviour must be the same as if I was using one broker?
Richard
Thanks for your time,
Richard Fallon
--
View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/Dynamic-Routes-and-Duplicate-Messages-tp6562267p6562267.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Re: Dynamic Routes and Duplicate Messages
Posted by fadams <fr...@blueyonder.co.uk>.
Scratch my last comment Gordon I tried this again and realised what I'd
done....
I had started my consumer with x-match: all in the address (my consumer
queues stay up until deleted) 'cause x-match: all failed to deliver anything
I'd forgotten this when I tried again with x-match: any
so trying x-match all followed by x-match any and forgetting to delete the
x-match: all binding gave 1666 messages where I'd expect 1000 - it's weird
as x-match: all on its own fails to deliver anything.
This case seems to have forwarded a message for each binding so I get 1000
messages related to data-service=item-selection and 666 relating to
item-owner=fadams which relates to the line in the producer below
if ((i % 3) == 0) message.setStringProperty("item-owner", "jdadams");
else message.setStringProperty("item-owner", "fadams");
Although this is different to Richard's scenario it's still rather weird and
as this is forwarding messages separately for each match this could actually
be a similar issue to the one Richard has seen as his two consumers would
each add a binding. BTW my scenario was repeatable whether or not I included
a binding key.
Another thing I noted was that if I bound the consumer to the destination
broker before I created the dynamic route the binding doesn't get propagated
to the source broker. I'd have expected all existing bindings to be
propagated as well as newly added ones - this feels like another bug?
looks like I'm sticking with queue routes for headers exchange federation
for the forseeable :-)
Regards,
Fraser
fadams wrote:
>
> Hi Gordon,
> I tried this independently and this is just to report I get the same
> results as Richard.
>
> I had a consumer with an address
>
> "myqueue; {create: receiver, node: {x-declare: {arguments:
> {'qpid.policy_type': ring, 'qpid.max_size': 500000000}}, x-bindings:
> [{exchange: 'amq.match', queue: 'myqueue', key: 'data1', arguments:
> {x-match: any, data-service: item-selection, item-owner: fadams}}]}}"
>
>
>
--
View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/Dynamic-Routes-and-Duplicate-Messages-tp6562267p6591836.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Re: Dynamic Routes and Duplicate Messages
Posted by fadams <fr...@blueyonder.co.uk>.
Hi Gordon,
I tried this independently and this is just to report I get the same results
as Richard.
I had a consumer with an address
"myqueue; {create: receiver, node: {x-declare: {arguments:
{'qpid.policy_type': ring, 'qpid.max_size': 500000000}}, x-bindings:
[{exchange: 'amq.match', queue: 'myqueue', key: 'data1', arguments:
{x-match: any, data-service: item-selection, item-owner: fadams}}]}}"
My test producer runs 1000 iterations, every message has
data-service=item-selection set and I've got a line
if ((i % 3) == 0) message.setStringProperty("item-owner", "fadams");
else message.setStringProperty("item-owner", "jdadams");
to twiddle with item-owner just to see what happens.
I did qpid-route dynamic add localhost:5673 localhost:5672 amq.match
And my consumer counted 1666 items!!!!!! clearly I was expecting 1000 given
an x-match any - my address has key: 'data1' in the x-bindings.
I'm running 0.10 brokers
So it doesn't look like the binding key suggestion works.
I guess if your trunk version also includes your "x-match:all" fix perhaps
there's something in there that sorts out the duplicates issue too?
Regards
Frase.
Gordon Sim wrote:
>
> On 07/15/2011 04:43 PM, Fallon, Richard wrote:
>> FYI - I have tried adding unique keys to each of the subscribers but
>> unfortunately still get the same results.
>
> Hmmm... it worked for me (albeit on trunk, but I don't *think* that
> should make a difference here).
>
>
>
--
View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/Dynamic-Routes-and-Duplicate-Messages-tp6562267p6587695.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Re: Dynamic Routes and Duplicate Messages
Posted by Gordon Sim <gs...@redhat.com>.
On 07/15/2011 04:43 PM, Fallon, Richard wrote:
> FYI - I have tried adding unique keys to each of the subscribers but
> unfortunately still get the same results.
Hmmm... it worked for me (albeit on trunk, but I don't *think* that
should make a difference here).
Did you restart the brokers? The duplicate keys would likely also
prevent correct unbinding and it is possible that if you didn't restart
(or explicitly delete them), the old duplicate bindings would still exist.
If this doesn't explain it, can you describe the steps again? I followed
more or less the procedure in your original mail and by using unique
keys eliminated the duplicates.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
RE: Dynamic Routes and Duplicate Messages
Posted by "Fallon, Richard" <ri...@atos.net>.
Hi Gordon,
FYI - I have tried adding unique keys to each of the subscribers but
unfortunately still get the same results.
Richard
-----Original Message-----
From: Gordon Sim [mailto:gsim@redhat.com]
Sent: 14 July 2011 16:59
To: users@qpid.apache.org
Subject: Re: Dynamic Routes and Duplicate Messages
On 07/14/2011 04:40 PM, rfallon wrote:
> I'll have a go at using a unique key and let you know how I get on.
Great, btw I meant using a unique key on your subscribers here, not on
the federated route.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
_______________________________________________________
Atos and Atos Consulting are trading names used by the Atos group. The following trading entities are registered in England and Wales: Atos IT Services UK Limited (registered number 01245534), Atos Consulting Limited (registered number 04312380) and Atos IT Solutions and Services Limited (registered number 01203466) The registered office for each is at 4 Triton Square, Regents Place, London, NW1 3HG. The VAT No. for each is: GB232327983
This e-mail and the documents attached are confidential and intended solely for the addressee, and may contain confidential or privileged information. If you receive this e-mail in error, you are not authorised to copy, disclose, use or retain it. Please notify the sender immediately and delete this email from your systems. As emails may be intercepted, amended or lost, they are not secure. Atos therefore can accept no liability for any errors or their content. Although Atos endeavours to maintain a virus-free network, we do not warrant that this transmission is virus-free and can accept no liability for any damages resulting from any virus transmitted. The risks are deemed to be accepted by everyone who communicates with Atos by email.
_______________________________________________________
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Re: Dynamic Routes and Duplicate Messages
Posted by Gordon Sim <gs...@redhat.com>.
On 07/14/2011 04:40 PM, rfallon wrote:
> I'll have a go at using a unique key and let you know how I get on.
Great, btw I meant using a unique key on your subscribers here, not on
the federated route.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Re: Dynamic Routes and Duplicate Messages
Posted by rfallon <ri...@atosorigin.com>.
Hi Gordon,
Thanks for the update.
I'll have a go at using a unique key and let you know how I get on.
Richard
--
View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/Dynamic-Routes-and-Duplicate-Messages-tp6562267p6583763.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Re: Dynamic Routes and Duplicate Messages
Posted by Gordon Sim <gs...@redhat.com>.
On 07/08/2011 01:09 PM, reekahdoh wrote:
>
> Hello All,
>
> I'll try and keep this as simple as possible. I'm using C++ Apache Qpid
> v0.8, and am having a problem when using dynamic routes with the headers
> exchange.
>
> FIRSTLY:
>
> Send two messages the default headers exchange on a broker.
>
> One Message has the headers :data-format=standard, data-source=A
> One Message has the headers :data-format=standard, data-source=B
>
> Set up two subscriptions to the same broker.
>
> One subscription (A) listening on for messages where data-format=standard.
>
> One subscription (B) listening on for messages where data-source=B.
>
> EXPECTED RESULTS:
> (A) receives contains two messages, where the data-format=standard
> (B) receives one message, where the data-source = B
>
>
> So, if I run the above I get the correct expected results.
>
>
> HOWEVER ...
>
> Now introduce another broker. Link the two using a dynamic route on the
> headers exchange.
> Publish messages to BROKER_A and subscribe to messages on BROKER_B.
>
> I would expect the results to be the same as above but now what I see
> is:-
>
>
> ACTUAL RESULTS:
> (A) queue contains three messages
> (B) queue contains two message
>
>
> Somehow duplicates are being created when using the dyamic route. Is
> this a bug? I certainly would not expect to see this behaviour differ
> when using dynamic routes. It seems that the dynamic route picks up on the
> same message being delivered to each different subscription. Surely the end
> behaviour must be the same as if I was using one broker?
Apologies for the delay in responding! I believe it is a bug and have
raised https://issues.apache.org/jira/browse/QPID-3356 to track it.
There may be a workaround. It seems to me that the problem is connected
to the binding keys for each subscription being the same. If you are
able to assign unique keys (doesn't affect matching or routing for this
exchange type), then the problem is avoided.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Re: Dynamic Routes and Duplicate Messages
Posted by Gordon Sim <gs...@redhat.com>.
On 07/18/2011 02:05 PM, rfallon wrote:
> If I use two subscriptions that subscribe to "x-match:any", e.g.
>
> 1) x-bindings:[{exchange:'amq.match', key:'source', arguments :
> {x-match:any, data-source:A}}
> 2) x-bindings:[{exchange:'amq.match', key:'format', arguments :
> {x-match:any, data-format:standard}}
>
> I see duplicate messages for subscription (1).
>
> However if I use two subscriptions that subscribe to "x-match:all", e.g.
>
> 1) x-bindings:[{exchange:'amq.match', key:'source', arguments :
> {x-match:all, data-source:A}}
> 2) x-bindings:[{exchange:'amq.match', key:'format', arguments :
> {x-match:all, data-format:standard}}
>
> Then everything works as expected. I hope this is of some use!
>
Yes, that makes sense. I was using the x-match:all when testing the
workaround but it isn't a general solution.
The issue there is independent of the dynamic federation and is a bug in
the headers exchange itself where it is not ensuring that a message
matching multiple bindings to the same queue is enqueued only once.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Re: Dynamic Routes and Duplicate Messages
Posted by rfallon <ri...@atosorigin.com>.
Hi Gordon,
Ok - I have done some more testing using the unique keys and have some
interesting results.
To confirm I am re-starting the brokers before each trial, and am repeating
the general idea as specified at the top of this thread. However the key
information is below:-
Send two messages to a broker, with a dynamic route to another broker .
One Message has the headers :data-format=standard, data-source=A
One Message has the headers :data-format=standard, data-source=B
If I use two subscriptions that subscribe to "x-match:any", e.g.
1) x-bindings:[{exchange:'amq.match', key:'source', arguments :
{x-match:any, data-source:A}}
2) x-bindings:[{exchange:'amq.match', key:'format', arguments :
{x-match:any, data-format:standard}}
I see duplicate messages for subscription (1).
However if I use two subscriptions that subscribe to "x-match:all", e.g.
1) x-bindings:[{exchange:'amq.match', key:'source', arguments :
{x-match:all, data-source:A}}
2) x-bindings:[{exchange:'amq.match', key:'format', arguments :
{x-match:all, data-format:standard}}
Then everything works as expected. I hope this is of some use!
--
View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/Dynamic-Routes-and-Duplicate-Messages-tp6562267p6594653.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org