.net - Retrying messages where my code fails with AWS SQS -
i've been trying find out more information on having retry , error queue code fails rather having in-memory retries in application.
here's scenario:
i'm sending message saying along lines of:
"process output task - want's update xml file contents of stream".
i have code writes output xml file can occasionally fail , need retried it's possible part of application/person using file @ point in time.
what i'm trying "whenever ouput code fails, resend sqs message told start output process/send new 1 same info. hence retrying message." also, once retries , fails 100 times want move error queue.
does know of kind of implementation of this? i'm trying see that's been done before start implementing.
sqs everthing want already, without effort:
your code should put message queue says "process output task - want's update xml file contents of stream"
your worker tasks polls queue , gets message , begins work. use windows services this, chron job or scheduled task works well.
only if worker completes task delete message queue - last thing worker job should before quitting. doesn't remove message queue when gets it, removes message if succeeds in processing it.
if worker not complete, , message still in queue, after visibility timeout expires, messages in queue again (or more accurately visible in queue again) automatically - don't need put in queue.
to implement 'fail after 100 tries', you'll want setup 'dead letter queue': http://docs.aws.amazon.com/awssimplequeueservice/latest/sqsdeveloperguide/sqsdeadletterqueue.html
you tell if worker task has requested message 100 times (configurable 1 1000 times) , not processed it, automatically move message specified dead-letter-queue.
couldn't simpler - sqs work few clicks of mouse - need write code puts original message in first queue, work, , deletes message queue if/when task completes successfully..
Comments
Post a Comment