Вы можете просто использовать scope = "prototype" для вашего компонента.Вот несколько примеров.Маршрут:
from("timer://foo?period=30s")
.setBody(simple("bean:test?method=getDate"))
.log(LoggingLevel.INFO, "Body:${body}");
Боб:
<bean id="test" class="my.test.package.Test" scope="prototype" />
Код:
public class Test {
final Timestamp date;
public Test() {
this.date = new Timestamp(System.currentTimeMillis());
}
public Timestamp getDate() {
return date;
}
}
Выход:
2018-11-13 16:45:07,372 | INFO | #6 - timer://foo | route4 | 98 - org.apache.camel.camel-core - 2.16.3 | Body:2018-11-13 16:45:07.37
2018-11-13 16:45:37,371 | INFO | #6 - timer://foo | route4 | 98 - org.apache.camel.camel-core - 2.16.3 | Body:2018-11-13 16:45:37.37
2018-11-13 16:46:07,371 | INFO | #6 - timer://foo | route4 | 98 - org.apache.camel.camel-core - 2.16.3 | Body:2018-11-13 16:46:07.371
2018-11-13 16:46:37,375 | INFO | #6 - timer://foo | route4 | 98 - org.apache.camel.camel-core - 2.16.3 | Body:2018-11-13 16:46:37.375