问题
I am newbie to Apache Camel. How can i access Camel Default Idempotent Repository map in Java DSL.
Route:
from("file://C:/folderA?noop=true")
.to("file://C:/folderB")
.end();
When i say noop=true in route, then idempotent will be true. Now i need to get Idempotent map in java dsl. Please tell me how to access this?
Thanks in advance.
回答1:
If you want to access the underlying map, you should specify your own idempotentRepository
bean. Using the existing MemoryIdempotentRepository
should be pretty easy.
//Instantiate repository and get map
IdempotentRepository<String> repo = MemoryIdempotentRepository.memoryIdempotentRepository()
Map<String, Object> map = repo.getCache();
//Bind the repo to the Camel Context Registry using the id "repo"
//This changes depending upon how you are running Camel
//In your RouteBuilder...
from("file://C:/folderA?noop=true&idempotentRepository=#repo")
.to("file://C:/folderB")
.end();
来源:https://stackoverflow.com/questions/30758934/how-to-access-default-idempotent-repository-map-from-java-dsl