PacificNW_Lover
PacificNW_Lover

Reputation: 5374

Mechanism to Constantly Check HTTP Endpoint (every 10 seconds) using Java Spring

Lets say there's an external HTTP Endpoint (REST based) which is updating its data every ten seconds.

How to create a mechanism using Java 1.7 and Spring MVC for REST (this is not Spring Boot) that constantly calls the Endpoint and returns the results?

Is there an API to use to do this?

e.g.

Call a proper HTTP GET request

https://api.app.com/v1/exchangeRates/Europe?name=acme_company

returns:

{ "name" : "acme_company", "price" : "20 EUR"}

but the price changes every 10 seconds?

What options are out there to use when using Java 1.7 and Spring 4?

Upvotes: 0

Views: 711

Answers (1)

The Head Rush
The Head Rush

Reputation: 3357

Spring provides an @Scheduled annotation

@Scheduled(fixedRate=5000)
public void doSomething() {
    // something that should execute periodically
}

More information here.

Upvotes: 1

Related Questions