Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Camel POJO Bean Processor Singleton or Prototype?

Tags:

apache-camel

I'm using Camel's spring DSL to build routes and I'm using my POJO bean as a processor.

Initially, I as doing:

<bean ref="myPojoBeanProcessor"/>

where, 'myPojoBeanProcessor' was defined as a bean in my spring context.

Then, I switched to:

<bean beanType="com.mycompany.transformation.MyPojoBeanProcessor"/>

The Java DSL equivalent would be, I think:

from("xxx").bean(MyPojoBeanProcessor.class).xxx

I'm wondering if with the later approach, a bean object would be instantiated with every request or would the bean instance be cached and used as a singleton (like the default in spring).

I was unable to find an answer in the camel documentation or on google. Does anyone know the answer to this question?

like image 882
nemo Avatar asked Jan 17 '23 14:01

nemo


1 Answers

Why don't you just try it out :)

Camel will create an instance one time using the default no-arg constructor, and cache the instance, eg its singleton scoped.

like image 57
Claus Ibsen Avatar answered Feb 11 '23 20:02

Claus Ibsen