We have several file routes that have several 'when' clauses in a 'choice'
element (XML config).  I need a way to let the user disable some of the
'when' options at runtime.  Each 'when' clause currently just has a 'to'
file URI.

Note I can't just stop the route that picks up the file at the above 'to'
URI because if I did that the files would continue to be produced at the
'to' URL.

I need to somehow disable the 'when' so that the files never get directed
anywhere because we have an ortherwise/stop clause in the choice...so files
that are not recognized go nowhere which is the correct behavior.

I could possibly wrap each of the when elements with another choice/when
that simply checks a bean if the 'when' is enabled but it feels like Camel
might already handle this more elegantly.


Part 2:
If I go with the custom bean idea, is there a way to pass method parameters
to the bean inline in the simple (or some other) expression?  Currently I
set the method parameter in a camel header and then the bean gets it via
annotations but would prefer to pass it directly if possible.  E.g.
currently I have this just to check if the when is enabled.

<setHeader headerName="CamelRouteName">
    <simple>ingestXdomain_OC</simple>
</setHeader>
<choice>
    <when id="ingestXdomain_OC_Enabled">
        <simple>bean:routeEnabled?method=isEnabled</simple>
        <to
uri="file://{{gangplank.home}}/work/ingestXdomain/OC/?tempFileName=${file:name}.partial"/>
    </when>
    <otherwise>
        <stop/>
    </otherwise>
</choice>

-Dave

Reply via email to