AWS SQS - Resent Message and Delete message if needed

0

I need to queue messages to be sent and optionally resent these messages (with very short intervals, i.e a few seconds) until the consumer decides to delete them. However it seems like for SQS, a message must be in the visibility timeout before I can delete them; and if I set a visibility timeout, I cannot retrieve the same message again until a message is out of the visibility timeout. Is there a way to use SQS where I can do both things at the same time?

Note: Setting the visibility timeout to 0 is not an option because we want to keep the receipt handler of the message to be consistent; if the message gets re-queued the old receipt handler expires.

Kay
asked 7 months ago315 views
1 Answer
0

I am not exactly clear on what you are trying to achieve here.

You have a consumer that reads messages from the queue. The consumer then tries to do something with the message. What does it do with it?

Eventually, when the consumer is done processing the message it needs to delete it. If it takes the consumer long time to process the message, it needs to extend the visibility timeout, so it will not be consumed by a different consumer.

profile pictureAWS
EXPERT
Uri
answered 7 months ago
  • It reads the message and dynamically decides if it wants to delete the message. If yes, then it should remove it from the queue. If not, it should be back into the queue immediately so that other consumers can consume it.

    However, I would like the consumer to also have the ability to delete the message it has read before.

    The question here is I wouldn't know when the consumer decides to delete a message; so I cannot just extend the visibility timeout to 12hours, and that will disallow other consumers to read the message too.

  • I must say that that doesn't sound like the right approach. If you want to return it to the queue it may well be that you will be consuming it again. If you have different consumers that need to process different messages, you probably need different queues.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions