Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question

How to safetly update state of poison messages without commiting other side effects

We have a polling container with a registered EventExceptionHandler that simply logs the exception message. But when an exception occurs the delivery of message to polling container get’s stuck in an endless loop of redelivery.

Now the xap 10 documentation says (see below).

“If the type of the exception is know to be unrecoverable, an exception handler can be registered that will check the exception type (the cause of the ListenerExecutionFailedException), detect it, and not re-throw an exception, but instead write that entry wrapped in a “Poison Message” entry back into the space creating a dead letter queue that can be processed later on.”

This implies that if the exception isn’t re-thrown you can write the poison message (p.m.) back to space, but our event might have caused other side effects so I don’t want the transaction to commit. So I assume if I don’t change a property of the p.m. such that the polling container query no longer matches, it will carry on being re-delivered. So how do I update the offending p.m. in the EventExceptionHandler? Won’t we get a deadlock if I try to simply update the p.m. in another transaction initiated from the exception handler?

If anyone has an example of how this pattern is commonly solved it would be much appreciated.

asked 2014-11-19 12:54:31 -0500

jason.parr gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

The missing part concerns the retry counter:

"A retry counter can also be handled by creating a generic interface, for example called RetryMessageEntry, which certain messages will implement. That interface will allow to increment a counter and reset it. The counter field will be part of the entry (i.e. persisted in the space)."

Thus the handler can check whether or not the retry counter == MAX_RETRIES and take the appropriate action. The writing of the PM should not be affected by the transaction, as this should be achieved with a separate proxy that was not injected with a transaction manager.

Hope this helps

answered 2014-11-20 13:44:58 -0500

jb gravatar image
edit flag offensive delete link more


If you are catching the exception ,and not re throwing it,object will not get back to space.and there will be no loop,In the exception handler you can write another object of different type,to be handled by another dead letter polling later.

Ester gravatar imageEster ( 2014-11-23 02:34:49 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-11-19 12:54:31 -0500

Seen: 520 times

Last updated: Nov 20 '14