0

I have implemented a Spring-boot Camel batch application running every 5 mins which is using camel-sql component to query some data from table. I am using java DSL implementation and configuring my routing endpoints inside RouteBuilder.configure. Everything is working fine as expected. But now as part of optimization I am planning to cache some of the query results which are not changing frequently like some global configuration tables, location timezone table etc.

I have gone through Camel EHcache documentation, but not getting the right understanding of the standard way of implementation.

My expectation is like the following

Suppose my routing is,

from(timercomponent)
.to(SqlComponent1)
.process(ResultProcessor::processResult1)
.to(SqlComponent2) // needs to be cached
.process(ResultProcessor::processResult1)
....
...

I don't want SqlComponent2 to hit the DB always and it should use a cached value from the first execution with an expiry time of 1 week.

Also I just wanted to know which is the best cache implementation to be used in this scenario.

Girish007
  • 442
  • 6
  • 26
  • what are you not understanding? be specific – pvpkiran Jun 06 '18 at 08:34
  • I just wanted to know how to configure the sql component so that it will fetch the value from cache if it is existing and run the query only when the cache is expired or empty. – Girish007 Jun 07 '18 at 01:32
  • you are defining the cache. The document u mentioned has the example on how to use it. Give it a try and if u have any issue, do ask – pvpkiran Jun 07 '18 at 10:19

1 Answers1

0

What do you mean? Ehcache or something else? Or how to configure the Ehcache cache?

From the Ehcache point of view, you will need a Cache using a 1 week TTL expiry.

Then, it's been a while I've implemented caching with Camel but the doc seems to say that an Ehcache idempotent repository should do the trick.

Henri
  • 5,551
  • 1
  • 22
  • 29