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

Can't find splitter bean in registry using multiple camel contexts with "vm" endpoint

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.8.0, 2.8.1
    • Fix Version/s: 2.8.3, 2.9.0
    • Component/s: camel-core
    • Labels:
    • Environment:

      OS - Windows XP 32 Bit
      Java - Sun 1.6_26
      Camel - 2.8.0/2.8.1/2.9-SNAPSHOT

    • Patch Info:
      Patch Available
    • Estimated Complexity:
      Unknown

      Description

      The splitter component can use a bean with a "split method". It seems that this "split bean" is handled as expression and resolved lately using Camel Context from current exchange.

      If I send an exchange using a separate CamelContext ("client")

      <camelContext id="client" xmlns="http://camel.apache.org/schema/spring">
      </camelContext>

      to a route defined in another CamelContext ("server") using in-memory transport like "direct" or "vm"

      <camelContext id="server" xmlns="http://camel.apache.org/schema/spring">

      <route id="route02" trace="false" streamCache="false">
      <from uri="vm:route02"/>
      <split>
      <method bean ="stringLineSplitter" method="split"/>
      <log message="before sending: ${body}"/>
      <inOut uri ="vm:route04"/>
      <log message="after sending"/>
      </split>
      <to uri="mock:route02"/>
      </route>

      </camelContext>

      the test fails with

      "Cannot find class: stringLineSplitter" (Camel 2.8.0).
      "org.apache.camel.NoSuchBeanException - No bean could be found in the registry for: stringLineSplitter" (Camel 2.9-SNAPSHOT)

      If I understood Camel right it fails
      because it tries to resolve this bean based on client Camel Context
      which is still set at the current exchange send from "client" to "server" but it
      doesn't contain the bean.

      If I send an exchange using same "client" CamelContext to another route in
      "server" CamelContext involving "external" components like "jms" (ActiveMQ)

      <camelContext id="server" xmlns="http://camel.apache.org/schema/spring">

      <route id="route03" trace="false" streamCache="false">
      <from uri="jms:queue:route03"/>
      <split>
      <method bean ="stringLineSplitter" method="split"/>
      <log message="before sending: ${body}"/>
      <inOut uri ="vm:route04"/>
      <log message="after sending"/>
      </split>
      <to uri="mock:route03"/>
      </route>

      </camelContext>

      the test passed successfully. It seems that "jms" component creates a
      new exchange using "server" CamelContext.

        Attachments

        1. testcase.zip
          9 kB
          Bernd Fischer
        2. MethodCallExpression.java.diff
          0.7 kB
          Bernd Fischer

          Activity

            People

            • Assignee:
              njiang Willem Jiang
              Reporter:
              berndfischer63 Bernd Fischer
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: