skip to Main Content

I need to consume an external API to update or create data, I need to handle service down cases and don’t lose the data if the service went down for more than expected, what is the best approach to do this… thanks in advance.

2

Answers


  1. I think you can have some kind of internal database, maybe NoSQL database that stores all of the failed requests you tried to send.

    So when you send a request and it fails for any reason, then you will insert the failed request to that database.

    And you will make a recurring task that pulls all the data from that internal db, and retries to send the requests again. If the request is succeeded, then remove it from the internal db.

    Login or Signup to reply.
  2. If downtimes are happening a lot and you have also high traffic taking an asynchronous microservice approach could be best.

    Using a message queuing system like RabbitMQ you can store all requests with their data as a message on a Queue.

    Then another microservice which consumes those messages from the Queue can reach the external service and do the operation. If the external service is up, the operation is completed and the messages is removed from the Queue.
    If not RabbitMQ has dozens of configs for Retrying (reque after x secs etc)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search