0

I have a daemon which constantly pools an AWS SQS queue for messages, once it does receive a message, I need to keep increasing the visibility timeout until the message is processed.

I would like to set up an "on demand scheduler" which increases the visibility timeout of the message every X minutes or so and then stops the scheduler once the message is processed.

I have tried using the Spring Scheduler (https://spring.io/guides/gs/scheduling-tasks/) but that doesn't meet my needs since it's not on demand and runs no matter what.

  • This is done on a distributed system with a large fleet.
  • A message can take up to 10 hours to completely process.
  • We cannot set the default visibility timeout for the queue to be a high number (due to other reasons).

I would just like to know if there is a good library out there that I can leverage for doing this? Thanks for the help!

FidelCashflo
  • 513
  • 2
  • 10
  • 23

2 Answers2

0

The maximum visibility timeout for an SQS message is 12 hours. You are nearing that limit. Perhaps you should consider removing the message from the queue while it is being processed and if an error occurs or the need arises you can re-queue the message.

You can set a trigger for Spring Scheduler allowing you to manually set the next execution time. Refer to this answer. This gives you more control over when the scheduled task runs.

Community
  • 1
  • 1
jzonthemtn
  • 3,344
  • 1
  • 21
  • 30
0

Given the scenario, pulling a message (thus having the visibility timeout timer start) and then trying to acquire a lock was not the most feasible way to go about doing this (especially since messages can take so long to process).

Since the messages could potentially take a very long time to process and thus delete, its not feasible to keep having to increase the timeout for messages that you've pulled. Thus, we went a different way.

We first acquire a lock and then pull the message and then increase the visibility timeout to 11 hours, after we've gotten a lock.

FidelCashflo
  • 513
  • 2
  • 10
  • 23