Funtush
Funtush

Reputation: 3

How to call another API in monolithic application?

I am working on a Spring Boot project in which I have to send response to another project through an API. So, I have one API for my application in which I am processing the data and then have to send an API response to another project through different API. So is it possible to to do in a monolithic application or do I have to create a microservice for that?

I am trying to do in same application, but I'm not able to figure out the solution, how we can achieve this monolithic application?

Upvotes: 0

Views: 376

Answers (1)

Praveen E
Praveen E

Reputation: 976

Since you want a trigger in 3 days after payment, you can use schedulers.

If you are running your app in AWS, you can use AWS Event Bridge to call you API everyday morning. (There should be an alternatives in other cloud providers too). You API should call yourMethod() and run logic for you.

If you do not want to use the services like AWS Event Bridge and if you want to do it only using Spring Boot, Spring Boot has a cron job which you can use as a scheduler.

@Scheduled(cron = "0 15 9 ? * ?", zone = "Asia/Calcutta") //9.15 AM everyday in Indian Timezone. Format of time is sec-min-hour-dayOfMonth-Month-DayOfWeek. Don't use @Scheduled if you use AWS Event Bridge
@Async //add this to run the method in Background
public void yourMethod() {
    //your logic
}

And add your logic to check all the orders where current date - ordered date = 3 days. Send a notification accordingly.

There could be other ways possible in Spring. This is not the only solution

Upvotes: 1

Related Questions