0

I want to stored http request in databases and will generated response to it when required.

Is it possible to stored the http request in db and generate response to it after 1 day or more in spring boot/spring

2 Answers 2

1

Obviously yes. It is how you architect your system. What I could see is basically you are trying to do something on scheduled manner.

Try using @Scheduled annotation to perform scheduled tasks.

Refer this url

Make sure to have persistent layer which stores the requests and your scheduled tasks pick it up. If it needs to communicate with different systems as call back include it as part of your task.

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you for your quick reply, But in my requirement schedule condition is not based on time constraint
Then how do you want it to be done? Do you want to process in Async manner then?
I will have http request stored in db. I need to wait for one condition to be satisfied after that I need to generate response using request stored in db and send it to the target
My suggestion might little extensive from system design perspective but it will solve your problem.Try using pub-sub. First when the request comes acknowledge it and store in db. Next on the condition satisfied try publishing to a particular topic. Listener of the topic fetches the request from db and push it in call back api to target.
0

Depend on your system requirement, the server can work something like this:

  1. Client send http request to server

  2. Server saves http request (to DB, file, ... anything) and generate a unique request_id. Server returns this request_id to client.

  3. The next day, client will need to send a new http request to server to get the response, with previous request_id included.

  4. Server look for saved request_id, process it, and return response to client.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.