Hi

If you use JMX then there is JMX operations to clear.

Otherwise you can create an instance of the memory repo, and use in the
route, and from java code you can invoke its clear method to clear the
cache.
You can make that code also be executed by the end of the route if you add
it as onCompletion in the route or via a Processor on the exchange UoW.



On Wed, Apr 19, 2023 at 9:52 AM Reto Peter <reto.pe...@advanceit.ch> wrote:

> Hi all
>
> I have a route, which checks for uniqueness of a certain value (find
> duplicates, and in case of duplicates, the route will throw an exception).
> That works fine so far.
>
> At the end of the route, I want to clear the cache, so next time the route
> gets executed, it shall start with an empty cache.
>
> My question: How can I clear the cache at the end of the route?
>
> My route(simplified)
>
>
> from("direct:processArticles")
>
>       .split(xpath("//Article")) // for each Article
>
>              .setHeader("ArtEAN", xpath("Article/ArtEAN/text()"))
>
>              .idempotentConsumer(header("ArtEAN"),
> MemoryIdempotentRepository.memoryIdempotentRepository(2000)).skipDuplicate(false)
>
>
> .choice().when(header(Exchange.DUPLICATE_MESSAGE).isEqualTo(true)).throwException(ImportException.class,
> "Line/Unit: ${exchangeProperty.CamelSplitIndex}: Found Duplicates").end()
>
>              // do some processing
>
>       .end()
>
> Camel 3.20.3, Spring Boot 2.7.10
>


-- 
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to