Reputation: 561
I've recently been working on setting up a project to use Azure and part of that involves requesting a token to access a REST API. I've been told that the token will expire in 30 minutes, but calling the API to get a new token isn't particularly expensive. I can do all this without any issue, but I'm curious if Camel has anything built in that can handle this for me without having to explicitly call to get a new token?
Upvotes: 1
Views: 808
Reputation: 11600
I don't know of anything built in, but you could have a timer route that runs every 25 minutes that requests a token and puts it in some kind of global state.
from("timer:getAuthToken?period=1500000")
.to("http:myKeyServer/getKey")
.process(new MyKeyProcessor()) // store in global state, static, spring, etc.
Then any route that needs the key can get it from global state and set it in a header or exchange property.
Upvotes: 1