3

There is a bean declared in a Spring boot configuration class with lazy annotation, which is referenced in camel route. The lazy annotation stops the eager loading, but since it is reference in camel route its gets initialized. Example :: ChoiceDefinition org.apache.camel.model.ProcessorDefinition.bean(Object bean, String method)

Is there any way of lazy loading of beans referenced in the camel route ?

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90

1 Answers1

2

No, because Camel needs to "build" and start the route, it also needs to initialize the Bean. You would have to lazy load the route.

You could try to disable autostart on the route and check if the bean is no more initialized when the route does not start.

If this is the case, you could use the Controlbus component to start your routes only when needed (and therefore initialize your beans only when needed).

burki
  • 6,741
  • 1
  • 15
  • 31