I've talked about The Message Consumer Rollback Pattern, which says that if a message is valid but cannot be processed, you should roll back the transaction to put the message back on the destination. But then won't this cause the message to be read and rolled back forever?
Yes, unfortunately messages will tend to retry forever, at least until the problem processing the messages is resolved. To prevent this, you need a way to detect this circumstance and respond by stopping the consumers. The idea is that if they can't process messages successfully anyway, they should stop consuming messages until the problem is resolved and processing will be successful.
In WAS 5.x, the listener port could detect a message that rolled back too many times and would stop. We lost this capability in WAS 6.x when we use activation specs to configure the connection between an MDB class and a JMS destination in the service integration bus (SIBus).
We have now regained this capability with activation specs with this patch: PK49507: The SIBus resource adapter will now indicate that an MDB should be stopped if a certain number of failures are hit. I talk about this in detail on my wiki: Pausing SIBus MDBs. (Thanks to Perficient's Dan Zrobok for pointing out this patch to me.)
In the process of documenting that, I also added or updated the following wiki pages:
- J2EE Connector Architecture
- Java Technologies
- Enterprise JavaBeans
- Miscellaneous Technologies
- Messaging Patterns
- Java Database Connectivity
- IBM Software Support