[
https://issues.apache.org/jira/browse/CAMEL-14488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17029980#comment-17029980
]
Claus Ibsen commented on CAMEL-14488:
-------------------------------------
You can use <bean> instead where you can set cache=false in Camel 3.0.
And in Camel 3.1 there is a bean scope option (instead of cache) which you can
set to scope=request, which will then lookup the bean once for each
request/exchange. Or use prototype scope which will lookup each time.
> SCOPE_PROTOTYPE doesn't work always (apache-camel.version 3.0.0-RC3)
> --------------------------------------------------------------------
>
> Key: CAMEL-14488
> URL: https://issues.apache.org/jira/browse/CAMEL-14488
> Project: Camel
> Issue Type: Bug
> Components: camel-spring
> Affects Versions: 3.0.0.RC3
> Environment: OS: Window 10 / 1809
> java version "11.0.3" 2019-04-16 LTS
> Spring: 2.2.0.RELEASE
> Reporter: Thomas Thiele
> Priority: Major
> Attachments: camel-prototype-verification.2020-02-04.7z
>
>
> After switch from apache-camel.version 3.0.0-M2 to 3.0.0-RC3 annotation
> _@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE_)
> seems not to work as usual.
> Complete sample project is attached
> (_camel-prototype-verification.2020-02-04.7z_).
> Run test: ``_mvn clean package_`` /or run test folder in your IDE.)
> For test you may switch the apache-camel.version in _pom.xm_l (see ``TODO``).
> Sample:
> {{In a camel route with reference to both classes, the _ValueChangedFilter_
> class is instantiated
> every time the _ValueChangedFilter.matches (Exchange exchange)_ method is
> called.
> Class _ValueChangedProcessor_ is instantiated only once (as expected).
> In apache-camel.version 3.0.0-M2 both classes are treated the same (like
> class _ValueChangedProcessor_).
> ```
> @Component
> @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
> public class ValueChangedFilter {
> public boolean matches(Exchange exchange)
> { // do something ... }
>
> }
>
> @Slf4j
> @Component
> @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
> public class ValueChangedProcessor implements Processor {
>
> @Override
> public void process(Exchange exchange)
> \{ // do something ... }
> }
> }}
> // CamelRoutes:
> ?xml version="1.0" encoding="UTF-8"?>
> <routes xmlns="http://camel.apache.org/schema/spring">
> <route id="filterRoute">
> <from uri="direct:GENERATOR_Filter_EntryPoint"/>
> <filter>
> <method ref="valueChangedFilter" method="matches(${exchange})"/>
> <stop/>
> </filter>
> <to uri="mock:messageReceiverFilter"/>
> </route>
> <route id="processorRoute">
> <from uri="direct:GENERATOR_to_Processor_EntryPoint"/>
> <process ref="valueChangedProcessor"/>
> <to uri="mock:messageReceiverProcessor"/>
> </route>
> </routes>
> ```
--
This message was sent by Atlassian Jira
(v8.3.4#803005)