You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by david_geary <da...@lagan.com> on 2009/02/25 13:20:21 UTC

Combination of filters

Hi, 

I'm using an xpath filter in the xml configuration eg 

<filter> 
<xpath>//cs:case/@queue="13"</xpath>
<to uri=..../>	  
</filter>

What's the easiest way to combine filters eg I want to accept it if its on
queue 13 OR 14 (or if on queue 13 AND some other attribute is a particular
value?)

I know I can set up separate filters and chain them to get 'AND' logic or 
achieve 'OR' logic by putting the results onto the same seda queue say but
is there an easier general way to do this with the <filter> or <xpath> xml
syntax?

Thanks 

Dave
-- 
View this message in context: http://www.nabble.com/Combination-of-filters-tp22201686p22201686.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.


Re: Combination of filters

Posted by Ashwin Karpe <as...@progress.com>.
Hi,

No. There is no simple way to do this unless you do this using something
like

    from("SourceURL").
	  filter().method("myBean", "isAtrributeQueue13or14"). 
    to("TargetURL"); 

Obviously you will need to parse the payload and determine whether the queue
attribute is 13 or 14. 

You can also use a scripting language to achieve the above effect.

Hope this helps.

Cheers,

Ashwin...


david_geary wrote:
> 
> Hi, 
> 
> I'm using an xpath filter in the xml configuration eg 
> 
> <filter> 
> <xpath>//cs:case/@queue="13"</xpath>
> <to uri=..../>	  
> </filter>
> 
> What's the easiest way to combine filters eg I want to accept it if its on
> queue 13 OR 14 (or if on queue 13 AND some other attribute is a particular
> value?)
> 
> I know I can set up separate filters and chain them to get 'AND' logic or 
> achieve 'OR' logic by putting the results onto the same seda queue say but
> is there an easier general way to do this with the <filter> or <xpath> xml
> syntax?
> 
> Thanks 
> 
> Dave
> 


-----
--- 
Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence 
Progress Software Corporation
14 Oak Park Drive
Bedford, MA 01730
--- 
+1-972-304-9084 (Office) 
+1-972-971-1700 (Mobile) 
---- 
Blog: http://opensourceknowledge.blogspot.com/


-- 
View this message in context: http://www.nabble.com/Combination-of-filters-tp22201686p22229308.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.


Re: Combination of filters

Posted by James Strachan <ja...@gmail.com>.
2009/2/25 david_geary <da...@lagan.com>:
>
> Hi,
>
> I'm using an xpath filter in the xml configuration eg
>
> <filter>
> <xpath>//cs:case/@queue="13"</xpath>
> <to uri=..../>
> </filter>
>
> What's the easiest way to combine filters eg I want to accept it if its on
> queue 13 OR 14 (or if on queue 13 AND some other attribute is a particular
> value?)
>
> I know I can set up separate filters and chain them to get 'AND' logic or
> achieve 'OR' logic by putting the results onto the same seda queue say but
> is there an easier general way to do this with the <filter> or <xpath> xml
> syntax?

XPath supports AND and OR too? So you could just use those inside the
XPath expression?
http://www.w3.org/TR/xpath#booleans

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Re: Combination of filters

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Feb 25, 2009 at 2:32 PM, Roman Kalukiewicz
<ro...@gmail.com> wrote:
> 2009/2/25 david_geary <da...@lagan.com>:
>>
>> Hi,
>>
>> I'm using an xpath filter in the xml configuration eg
>>
>> <filter>
>> <xpath>//cs:case/@queue="13"</xpath>
>> <to uri=..../>
>> </filter>
>>
>> What's the easiest way to combine filters eg I want to accept it if its on
>> queue 13 OR 14 (or if on queue 13 AND some other attribute is a particular
>> value?)
>>
>> I know I can set up separate filters and chain them to get 'AND' logic or
>> achieve 'OR' logic by putting the results onto the same seda queue say but
>> is there an easier general way to do this with the <filter> or <xpath> xml
>> syntax?
>
> There is org.apache.camel.builder.PredicateBuilder class that has
> helper methods that allows you to nicely combine Predicates.
> Unfortunately it helps with Java DSL only.
>
Take a look at his blog entry demonstrating how to use the Java DSL
predicate to combine predicates.
http://davsclaus.blogspot.com/2009/02/apache-camel-and-using-compound.html


-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/

Re: Combination of filters

Posted by Roman Kalukiewicz <ro...@gmail.com>.
2009/2/25 david_geary <da...@lagan.com>:
>
> Hi,
>
> I'm using an xpath filter in the xml configuration eg
>
> <filter>
> <xpath>//cs:case/@queue="13"</xpath>
> <to uri=..../>
> </filter>
>
> What's the easiest way to combine filters eg I want to accept it if its on
> queue 13 OR 14 (or if on queue 13 AND some other attribute is a particular
> value?)
>
> I know I can set up separate filters and chain them to get 'AND' logic or
> achieve 'OR' logic by putting the results onto the same seda queue say but
> is there an easier general way to do this with the <filter> or <xpath> xml
> syntax?

There is org.apache.camel.builder.PredicateBuilder class that has
helper methods that allows you to nicely combine Predicates.
Unfortunately it helps with Java DSL only.