Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

To use a Python expression use the following Java code

Code Block
languagetext

... python("somePythonExpression") ... 

...

In the sample below we use Python to create a Predicate use in the route path, to route exchanges from admin users to a special queue.

Code Block
java
java

    from("direct:start")
        .choice()
            .when().python("request.headers['user'] == 'admin'").to("seda:adminQueue")
        .otherwise()
            .to("seda:regularQueue");

And a Spring DSL sample as well:

Code Block
xml
xml

    <route>
        <from uri="direct:start"/>
        <choice>
            <when>
                <python>request.headers['user'] == 'admin'</python>
                <to uri="seda:adminQueue"/>
            </when>
            <otherwise>
                <to uri="seda:regularQueue"/>
            </otherwise>
        </choice>
    </route>

Include Page

...

Scripting Languages Context

...

Scripting Languages Context