activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marco Buss <>
Subject Re: Closing a consumer create more messages than sent
Date Fri, 06 Jun 2008 12:51:38 GMT

Hi Kevin

I take a look on your Test. I think you have a little misunderstanding about
the acknoledge. If you use transactional Session, the ack is send with the
commit();. 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. Be aware of
mMessagesRecieved > lMessagesSent. If all works fine the mMessagesRecieved
will never be greater than lMessagesSent and so your code go to an infinit

Another way is to say explicit the no ack is needed. To do that change your
mConnFact = new ActiveMQConnectionFactory(DEFAULT_URL);
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,
also i have rmoved the commit(); because it is not needed with


kloh wrote:
> Hi Marco,
> Marco Buss wrote:
>> what acknoledge mode did you use? Session.AUTO_ACKNOWLEDGE?
>> try to use Session.CLIENT_ACKNOWLEDGE an then send the ACK manualy.
> we use transactional sessions, so no (??) acknowledge mode is used.
> Marco Buss wrote:
>> I`t would be fine if you can provide a junit-test for the Problem.
> I attached some classes with the activemq-5.1-jar and our
> activemq-configuration file: 
> You have to change the url of the messagebroker in the ''-file.
> Maybe you can play a bit with the values in the same file. The JUnit is in
> the 'MainTest'-class.
> I appreciate your effort.
> Kevin

View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message