In my testing of JMS messaging using regular JMS transactions, I noticed that if the same message was received but then rolled back seven times in a row, it would disappear out of the message queue. “Odd,” I thought. So I looked in the ActiveMQ API docs for the Session interface (and its implementors)’ rollback method and in the activemq.xml configuration file, but did not see a setting there for this.
Next I searched the activemq forums for postings about rollbacks and found this message, which points you to an activemq.dtd file. The link is dead, and it appears that the .dtd file has been replaced with an .xsd, activemq.xsd, which I found in the activemq-all-5.1.0.jar file. I pored through this schema until I noticed a “redeliveryPolicy” element with a “maximumRedeliveries” attribute. I bet that’s how you configure this.
Somewhere along in here, I thought of trying to go to the link http://activemq.apache.org/schema/core. (Probably because I saw this string in the activemq.xml configuration file.) I found the redeliveryPolicy element in the HTML view of the xsd file.
So, it appears that the setting is configurable and that the hierarchy to get to the redeliveryPolicy element is broker -> regionBroker -> commandAgent -> connectionFactory -> redeliveryPolicy… but I can’t figure out how to get the regionBroker element in the XML. There’s already a <broker> element in the activemq.xml configuration file, and I tried adding a <regionBroker> under that, but ActiveMQ choked when I tried to start it up. (Also Eclipse’s auto-complete (Ctrl+Space) doesn’t show regionBroker as one of the valid element types I can add there… but come to think of it, Eclipse’s auto-complete in this case is only showing as available the elements that already exist in activemq.xml, so maybe I can’t trust it to show me everything that’s available in this case.)
The schema doc says that the the type of regionBroker is:
Update: Huh – they’re not being discarded at all… there’s an ActiveMQ.DLQ (Dead Letter Queue, get it? :) queue that has 16 messages in it. When I thought the messages were being discarded, they were being put in there.
Update July 8, 2008: I found the ActiveMQ documentation for the Redelivery Policy.