activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marco Buss <marco.b...@gmx.de>
Subject Re: Closing a consumer create more messages than sent
Date Mon, 09 Jun 2008 09:03:51 GMT




kloh wrote:
> 
> Marco,
> 
> thanks for having time for looking at it!
> 
> 
> 
>> The problem in your code is the closing and creating of a new consumer.
>> If you close the old one, he had not enough time to send the ack for the
>> last message. So the broker thinks the Message is lost or there are
>> another problem and he sneds the message twice to the new consumer.
>> 
>> I have insert a little break after the closing of the consumer before the
>> new consumer is created. After that all works like you expected.
>> 
> But is this the correct way? I mean, to make just a little pause after
> closing isn't a nice way, is it? I can't imagine, that the
> ActiveMQ-developers want this to be done by a user...
> 

I think ActiveMQ shows the right behavior. The broker needs an ack for the
receving of the message. The ack is not send to the server and so he sends
the message twice because he thinks the message is not processed. The Broker
dont`t know that the message is processed but the thread is closed before
the ack is send. The right way for this would be to ensure the thread is
closed after the ack is send.


kloh wrote:
> 
> 
> 
> 
>> Another way is to say explicit the no ack is needed. To do that change
>> your connector.
>> mConnFact = new ActiveMQConnectionFactory(DEFAULT_URL);
>> 	((ActiveMQConnectionFactory)mConnFact).setAlwaysSessionAsync(true);
>> 	((ActiveMQConnectionFactory)mConnFact).setUseAsyncSend(true);
>> 	((ActiveMQConnectionFactory)mConnFact).setDispatchAsync(true);
>> I`m not shure if you need all the three. Try it out. A have also changed
>> the consumer a little bit for that.
>> mJMSSession = mConnector.lookupConnection().createSession(false,
>> 					Session.AUTO_ACKNOWLEDGE);
>> also i have rmoved the commit(); because it is not needed with
>> AUTO_ACKNOWLEDGE
>> 
> No, thats no option! We do use transactions and don't want to change it!
> 
> Thanks for the reply, I'll give the pause after closing one consumer a
> chance but I'm not happy with it!
> 
> Cheers,
>  Kevin
> 

Ok, that's ok. But it is not clear why you must use transactions. Please
describe it a little bit. Sometime the transaction is not realy needed.

-- 
View this message in context: http://www.nabble.com/Closing-a-consumer-create-more-messages-than-sent-tp17602690p17728926.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message