Skip to main content

TransactionManager RETRY

· 2 min read
Alejandro Revilla
jPOS project founder

/by apr/ For some time I have been playing with the idea of supporting a PAUSE action at prepare time in the jPOS transaction manager (think continuations), but it has some side effects related to transaction recovery, so it is still in the works. But I´ve added an easy to use and handy RETRY action that you can use while implementing your participants. If you return RETRY at prepare time, the TransactionManager will store your context in the persistent space and will re-queue it at regular intervals (default to 5 seconds, configured by a retry-interval property) back into the main queue. Imagine you have a system that connects to different remote processors and one processor goes slow or down for a while. Even if you are handling a big number of concurrent sessions, eventually all sessions might get locked waiting for responses coming from that particular endpoint. You could solve a situation like this by using multiple transaction manager instances (one per endpoint) but with this new RETRY thing, you can just RETRY the transaction at a later time (usually a few seconds later). You can place a retry counter in the context, or check the timestamp in order to avoid retrying the transaction forever. There´s an example in jpos6/modules/txnmgr/test/org/jpos/transaction/TestRetryParticipant.java.