How to access Default Idempotent Repository map from java dsl?

843 Views Asked by At

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

There are 1 best solutions below

2
On

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();