Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-14488

SCOPE_PROTOTYPE doesn't work always (apache-camel.version 3.0.0-RC3)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Won't Fix
    • 3.0.0.RC3
    • None
    • camel-spring
    • None
    • OS: Window 10 / 1809
      java version "11.0.3" 2019-04-16 LTS
      Spring: 2.2.0.RELEASE

    • Unknown

    Description

      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>
      ```

      Attachments

        Activity

          People

            Unassigned Unassigned
            BAW08 Thomas Thiele
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: