You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by dbczak <za...@dbconcert.com> on 2009/09/14 20:25:53 UTC

Duplicate Messages on Listener Restart

Hi,

I have a message client that produces a message and sends to multiple
listeners by using the URL:
fanout:(static:(tcp://host1:61616,tcp://host2:61616,tcp://host3:61616
...))?fanOutQueues=true&minAckCount=1 

I'm getting duplicate messages whenever any of the listener is shut down and
restarted but the sender is not.  For example:

I start 2 listeners.
I run the sender which sends one message - both listeners receive and
acknowledge.
I shut down one of the listeners.
The sender then sends another message which only reaches one of the
listeners.
I bring the listener that is down back up.  - At this point, this listener
receives both the first message that it already processed and the new
message it missed.  It should only receive the one it missed, but I can't
stop the other one from coming in too.

The code for both the listener (TIPServer.java) and sender (TIPClient.java) 
are attached.  

http://www.nabble.com/file/p25440673/TIPServer.java TIPServer.java 

http://www.nabble.com/file/p25440673/TIPClient.java TIPClient.java 
-- 
View this message in context: http://www.nabble.com/Duplicate-Messages-on-Listener-Restart-tp25440673p25440673.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Duplicate Messages on Listener Restart

Posted by Rob Davies <ra...@gmail.com>.
On 15 Sep 2009, at 11:29, dbczak wrote:

>
> I used fanout because I need the producer to send the same message to
> multiple consumers - but only once to each consumer.  How do I do this
> without getting duplicates when the consumer restarts?  What should  
> the url
> be?
> -- 
> View this message in context: http://www.nabble.com/Duplicate-Messages-on-Listener-Restart-tp25440673p25451637.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>


just use a normal url for the consumers - not a fanout one.

Rob Davies
http://twitter.com/rajdavies
I work here: http://fusesource.com
My Blog: http://rajdavies.blogspot.com/
I'm writing this: http://www.manning.com/snyder/






Re: Duplicate Messages on Listener Restart

Posted by dbczak <za...@dbconcert.com>.
I used fanout because I need the producer to send the same message to
multiple consumers - but only once to each consumer.  How do I do this
without getting duplicates when the consumer restarts?  What should the url
be?  
-- 
View this message in context: http://www.nabble.com/Duplicate-Messages-on-Listener-Restart-tp25440673p25451637.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Duplicate Messages on Listener Restart

Posted by Bruce Snyder <br...@gmail.com>.
On Tue, Sep 15, 2009 at 6:01 AM, dbczak <za...@dbconcert.com> wrote:
>
> the consumers do have normal url's (see TIPServer.java).  But for the sender,
> what url do I use to send to multiple consumers?

Just use the normal URL - tcp://<broker-ip>:<port>

If you want all subscribers to get a copy of a message, then you
should be using topics for publish/subscribe style of messaging. On
the other hand, if you want only one consumer to receive each message,
then you should use queues for a point-to-point style of messaging.

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

ActiveMQ in Action: http://bit.ly/2je6cQ
Blog: http://bruceblog.org/
Twitter: http://twitter.com/brucesnyder

Re: Duplicate Messages on Listener Restart

Posted by dbczak <za...@dbconcert.com>.
I'm very new to ActiveMQ, and this is probably a problem with the way I'm
using it.  I do not know how to create a JIRA.  It would be hard to create a
test case without the extra processing code included. The test would be as
follows:

1) Run TIPServer.java in 2 locations.
2) Create a new instance of TIPClient in a 3rd location and call sendData(). 
This method does some db lookups and other processing to create a message
and then call producer.send.
3) Shut down one of the TIPServer instances.
4) Call sendData() again on the same instance of TIPClient from #2.
5) Bring TIPServer back up in the location where it was brought down.  When
it comes back up, it will process the first sent message again.



-- 
View this message in context: http://www.nabble.com/Duplicate-Messages-on-Listener-Restart-tp25440673p25454456.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Duplicate Messages on Listener Restart

Posted by Rob Davies <ra...@gmail.com>.
On 15 Sep 2009, at 13:01, dbczak wrote:

>
> the consumers do have normal url's (see TIPServer.java).  But for  
> the sender,
> what url do I use to send to multiple consumers?
> -- 
> View this message in context: http://www.nabble.com/Duplicate-Messages-on-Listener-Restart-tp25440673p25452663.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>


Ah - missed that - assumed that TIPServer was producing for some  
reason. Can you create a jira and attach a test case ?
Will make it quicker to work out what the issue is

thanks

Rob Davies
http://twitter.com/rajdavies
I work here: http://fusesource.com
My Blog: http://rajdavies.blogspot.com/
I'm writing this: http://www.manning.com/snyder/






Re: Duplicate Messages on Listener Restart

Posted by dbczak <za...@dbconcert.com>.
the consumers do have normal url's (see TIPServer.java).  But for the sender,
what url do I use to send to multiple consumers?
-- 
View this message in context: http://www.nabble.com/Duplicate-Messages-on-Listener-Restart-tp25440673p25452663.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Duplicate Messages on Listener Restart

Posted by Rob Davies <ra...@gmail.com>.
On 15 Sep 2009, at 04:15, Bruce Snyder wrote:

> On Mon, Sep 14, 2009 at 12:25 PM, dbczak <za...@dbconcert.com> wrote:
>>
>> Hi,
>>
>> I have a message client that produces a message and sends to multiple
>> listeners by using the URL:
>> fanout:(static:(tcp://host1:61616,tcp://host2:61616,tcp://host3:61616
>> ...))?fanOutQueues=true&minAckCount=1
>>
>> I'm getting duplicate messages whenever any of the listener is shut  
>> down and
>> restarted but the sender is not.  For example:
>>
>> I start 2 listeners.
>> I run the sender which sends one message - both listeners receive and
>> acknowledge.
>> I shut down one of the listeners.
>> The sender then sends another message which only reaches one of the
>> listeners.
>> I bring the listener that is down back up.  - At this point, this  
>> listener
>> receives both the first message that it already processed and the new
>> message it missed.  It should only receive the one it missed, but I  
>> can't
>> stop the other one from coming in too.
>>
>> The code for both the listener (TIPServer.java) and sender  
>> (TIPClient.java)
>> are attached.
>>
>> http://www.nabble.com/file/p25440673/TIPServer.java TIPServer.java
>>
>> http://www.nabble.com/file/p25440673/TIPClient.java TIPClient.java
>
> What behavior are you expecting by using the fanout transport and the
> fanOutQueues=true transport option?
>
> Please make sure to read everything on the following page regarding
> the fanout transport:
>
> http://activemq.apache.org/fanout-transport-reference.html
>
> Bruce
> -- 
> perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\! 
> G;6%I;\"YC;VT*"
> );'
>
> ActiveMQ in Action: http://bit.ly/2je6cQ
> Blog: http://bruceblog.org/
> Twitter: http://twitter.com/brucesnyder


I think the main thing to note is to not use fanout:// transport for  
consumers - its for producers only

cheers,

Rob Davies
http://twitter.com/rajdavies
I work here: http://fusesource.com
My Blog: http://rajdavies.blogspot.com/
I'm writing this: http://www.manning.com/snyder/






Re: Duplicate Messages on Listener Restart

Posted by Bruce Snyder <br...@gmail.com>.
On Mon, Sep 14, 2009 at 12:25 PM, dbczak <za...@dbconcert.com> wrote:
>
> Hi,
>
> I have a message client that produces a message and sends to multiple
> listeners by using the URL:
> fanout:(static:(tcp://host1:61616,tcp://host2:61616,tcp://host3:61616
> ...))?fanOutQueues=true&minAckCount=1
>
> I'm getting duplicate messages whenever any of the listener is shut down and
> restarted but the sender is not.  For example:
>
> I start 2 listeners.
> I run the sender which sends one message - both listeners receive and
> acknowledge.
> I shut down one of the listeners.
> The sender then sends another message which only reaches one of the
> listeners.
> I bring the listener that is down back up.  - At this point, this listener
> receives both the first message that it already processed and the new
> message it missed.  It should only receive the one it missed, but I can't
> stop the other one from coming in too.
>
> The code for both the listener (TIPServer.java) and sender (TIPClient.java)
> are attached.
>
> http://www.nabble.com/file/p25440673/TIPServer.java TIPServer.java
>
> http://www.nabble.com/file/p25440673/TIPClient.java TIPClient.java

What behavior are you expecting by using the fanout transport and the
fanOutQueues=true transport option?

Please make sure to read everything on the following page regarding
the fanout transport:

http://activemq.apache.org/fanout-transport-reference.html

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

ActiveMQ in Action: http://bit.ly/2je6cQ
Blog: http://bruceblog.org/
Twitter: http://twitter.com/brucesnyder