简体   繁体   中英

how to handle server downtime for webhook requests in java

My application(A) gets file processing details from another java application(B) through rest api. App B sends the status with real-time processing details (Inprogess, Generated, Transfered). Application reads this info and displays it to the user. when the status is Transfered.. App A performs some task.

App A is completely dependent on App B for performing future task.

The Communication between two application is one-way. App B -> App A. As of now App B perform some script for file processing and send details through rest-api. App B doesnt store this info anywhere.

Looking for best practise to handle the request from App B during my app A downtime.

I found that message queue is best solution for this usecase. Unfortunately we cant have any new infrastructure for message queue.

Is there any other solution that we can implement in java without having any infra level changes. I appreciate your time for going through this query. Thankyou

Assuming a DB exists in App B , you can simulate the queuing behavior.

Here is a naive implementation idea. Let's say you have a table like the following in App B to track all the calls to be made to App A .

task_id call_status last_retry_ts
001 NOT_CALLED null
002 WIP 2022-12-10T10:00:01
003 COMPLETE 2022-12-10T10:00:01

You can have a thread that will take all tasks that do not have a COMPLETE status and retry. Once a call is successful, the thread marks them in the DB. You may want to introduce some delay in between the delays.

Note: You may have to build some more bells and whistles to make it robust.

Hope this will give you some inspiration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM