1

My golang-application uses aws-sdk-go to interact with an input queue. One message from the queue is processed about 7-10 min by a goroutine and then deleted. I would like to hide the message in the input queue setting VisibilityTimeout to 10min because another goroutines should not process the same message in this time interval.

There are risks that I can get when app is shut down and its context is cancelled:

  1. If I do not reset VisibilityTimeout of a message somehow, I need to wait for it for 10min when app is restarted
  2. If context is canceled (app is shutting down), I can't invoke ChangeMessageVisibilityWithContext to reset VisibilityTimeout to 0 when app is shut down, because cancelled context prevents this and the invocation will fail with error. I can create new context for this case but this is not good idea for some reasons

How do I reset VisibilityTimeout for the input queue when app is restarted?

DisplayName
  • 219
  • 4
  • 23
  • "I can't invoke ChangeMessageVisibilityWithContext to reset VisibilityTimeout to 0" You can use ChangeMessageVisisbility instead and don't pass it a context. – erik258 Aug 26 '22 at 17:55
  • @DanielFarrell but how do I know this request is completed if I don't use context. But sounds reasonable – DisplayName Aug 26 '22 at 18:40
  • Context doesn't guarantee a request is completed. It's more commonly used as a mechanism to broadcast cancellation – erik258 Aug 26 '22 at 21:48

0 Answers0