add a timeout to the call to receive.
message = subscriber.receive(4000);
There is a race between a consumer checking for a message and the broker doing a first async dispatch, often the client wins and does not find a message if there is no wait timeout specified.
The example is simplified for readability. I actually did use some timeout, I even tried with message consumers. There is also no redelivery delay nor exponential backup configured.
When I change the persistence adapter to JDBC, I see the message in the database after sending, but as soon as the persistent subscriber receives the message (in a not-yet commited transaction), it gets removed from the database. So even if I call rollback() afterwards, the message cannot be redelivered again, as it doesn't seem to exist in the message store anymore.
When I switch to message queues, the messages get redelivered, which lets me think that this is a bug in the implementation of topics.
This is a bug. I have raised and resolved AMQ-3238 such that this will be fixed in the ActiveMQ 5.5.
Thanks for the simple test code that demonstrated the problem.
Edited by: gtully on Mar 23, 2011 11:32 AM
Edited by: gtully on Mar 23, 2011 11:35 AM
I was just about to raise a bug in JIRA and now have seen that you already fixed this issue. Thanks a lot for the quick reaction!