On Fri, Jun 8, 2012 at 8:07 AM, gramanero <graman...@gmail.com> wrote:
>
> If I let the transaction rollback, then I have the message on the queue
> still and then run the risk of trying to process it a second time which
> will result in the same scenario and most likely end up in an endless loop.
> Unless I configure the redelivery policy to only attempt to redeliver N
> times as opposed to an infinite numer of times.
>

With the "purgatory" pattern (best name I could think of at the time),
the transaction is allowed to rollback, but the message is
"blacklisted" and it sort of "bounces" back off the front of the
queue.  The next time the consumer grabs the message off the queue, it
recognizes that it has been blacklisted and it forwards it to the
purgatory queue (unless it has already been there too many times, then
it goes to the DLC queue) to sort of take a "time out."

There is a throttled (to keep it from thrashing) consumer on the
purgatory queue that inspects each message that comes off the queue.
If the message has fulfilled its timeout and it's ready to try to come
back and play nice, then it sends it back to where it came from (the
original input queue).  If not, then it just puts it back on the
purgatory queue (hence the possibility of thrashing) to be processed
again in a bit.

Again, at some point (hopefully today), I hope to implement a feature
which would allow the original input route (which consumes from the
input queue) to detect (still working on the algorithm) when it is
sending too much stuff to purgatory or DLC.  When that happens, it
will spin off a thread to suspend it's consumer.  It will also
schedule a timer task to come back and wake it up in a bit when
hopefully the problem (database down, web service unavailable, etc.)
has been addressed and everything is happy again.  The input queue
itself will still continue to function and receive messages.  The
consumer just won't be pulling messages off the front for a  little
while.

The one requirement we have that this does address is that messages
are definitely not lost, since all of the routes are transactional.

Reply via email to