loading...

Discussion on: Timeout with a third party library or another server - How to handle?

Collapse
eruizdechavez profile image
Erick Ruiz de Chavez

The solution depends mostly on the workflow, which is not described here, but an async way of solving this would be:

  • AS1 sends request to AS2 including a "job id" which can be easily generated using UUIDs.
  • AS2 works its (slow) magic and sends a request to AS1 with the result and the job UUID.
  • AS1 continues its process now.

Another approach could be to completely decouple AS1 and AS2 and use a message queue for the interactions.

  • Both AS1 and AS2 use a message queue MQ1.
  • AS1 creates a message on MQ1 in the right channel to be consumed by AS2 workers.
  • AS2 workers see a new message on their channel and consume it, doing their validations, storing in DB2 and finally pushing a new message in MQ1 in the right channel for AS1 workers.
  • AS1 workers see the message in their channel and consume with whatever logic is required.
Collapse
davelsan profile image
David Velasco

Mine is an uneducated opinion, but I like your second approach. It is very intuitive, the kind of logic I would expect from what appears to be a loosely coupled architecture.

Collapse
nav_devl profile image
Naveen Honest Raj Author

Thanks Eric. I know I didn't provide a complete picture in here, but after discussing your suggestions with my teammates, we felt the second approach you suggested goes well with our current scenario! Thanks again Eric :))

Collapse
eruizdechavez profile image
Erick Ruiz de Chavez

I am glad my (very generic) comment helped!