1

I am working on a requirement that asks me to call a specific endpoint after a successful to get some data. We achieved that using a SNS topic posted to a SQS queue which in turn calls an endpoint. SNS -> SQS -> My Endpoint (Process Q Message) -> Calls External Endpoint to get data.

Now, we have found out that data is not available immediately after order is processed and now the requirement is to keep trying every 30 seconds for 5 times.

Is there any way we can achieve this?

Right now, I have made it such that My endpoint which process the message from Queue always returns an error so that the message is retried.

I have the visibility timeout set to 30 seconds so that the message is re-tried every 30 seconds for 5 times.

Is there a better way to achieve what I want with my existing setup? Please help.

Viki
  • 11
  • 3
  • 1
    If SQS itself need to try again, I think whatever you did is the only approach. Otherwise modify the SNS's source to send notification only when "data is available". – kosa May 08 '17 at 18:18
  • Thanks, but the problem is, I wont know that the data is available until I make the call to the external endpoint – Viki May 08 '17 at 21:13
  • 2
    *Is there a better way to achieve what I want?* There's not really anything wrong with this solution. That's a viable use for visibility timeout. I have an application that waits 5 minutes between retries and that's exactly how I handle it. Given the fact that SQS is designed with a built-in limit such that each queue is "only" allowed to have 120,000 messages that have already been received at least once and have their visibility timeout timers running at any moment in time... it seems like they designed it to be used this way. – Michael - sqlbot May 09 '17 at 01:19

1 Answers1

0

Why not publish a message when said data is available, and then use that message only as the trigger? Then, the SQS message won't fail the first time.

If for some reason that isn't possible (shouldn't really be the case but YNK), then yeah just throw an error as you did, and it will retry. It should work.

The 0bserver
  • 826
  • 9
  • 18