Uploaded image for project: 'Red Hat Build of Apache Camel for Quarkus'
  1. Red Hat Build of Apache Camel for Quarkus
  2. CEQ-12256

Bean method does not work when worked with Choice EIP

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • 3.Next.GA
    • 3.20.0.GA, 3.27.0.GA
    • Camel Quarkus
    • None
    • False
    • Hide

      None

      Show
      None
    • False
    • Moderate
    • 0

      I have a simple route:

              <from uri="direct://start"/>
              <choice>
                  <when>
                      <xpath saxon="true">/*:test/*:foo/text() = 'bar'</xpath>
                      <log message="Condition met: foo equals bar"/>
                      <method ref="someBean" method="processFooBar"/>
                  </when>
                  <otherwise>
                      <log message="Condition not met: foo does not equal bar"/>
                  </otherwise>
              </choice>
      

      The xml input is as follows:

      <test><foo>not bar</foo><message>Hello, Camel in Quarkus!</message></test>
      

      The XPath expression was evaluated against the xml input as *false*. So the Bean method "someBean" should not be invoked. However, the camel still prints out:

      2025-12-17 11:04:07,531 INFO  [xx.xxx.xxx.SomeBean] (executor-thread-1) Inside SomeBean.processFooBar()
      

      Furthermore, when the xml input was evaluated as *true*, the <otherwise> block was still invoked. It seems that the Bean method had completed malfunctioned, and caused camel flow to malfunction too.

      Workaround:
      Change the Bean method to Bean component should resolve the issue. For instance:

              <from uri="direct://start"/>
              <choice>
                  <when>
                      <xpath saxon="true">/*:test/*:foo/text() = 'bar'</xpath>
                      <log message="Condition met: foo equals bar"/>
                      <!--method ref="someBean" method="processFooBar"/-->
                      <to uri="bean:someBean?method=processFooBar"/>
                  </when>
                  <otherwise>
                      <log message="Condition not met: foo does not equal bar"/>
                  </otherwise>
              </choice>
      

              Unassigned Unassigned
              rhn-support-qluo Joe Luo
              Lukas Lowinger Lukas Lowinger
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: