And/Or/Not Logic Filters
Allows filtering of messages using And/Or/Not logic expressions.
Minimum Configuration: None.
Filter Configuration
Logic filters apply the And, Or, Not logic to one or more nested filters that they enclose. When you use these logic filters, you add nested filters to them from within the nested pane for the And, Or, Not filter.
-
In Anypoint Studio, search for "logic" and drag the Filter Reference block to the Canvas.
-
Click the processor to open the properties editor:
-
Click the green plus sign to the right of Global Reference.
-
Click the down arrow for Filters to show the filter selections:
-
Click And and OK.
-
Click the green plus sign below And-Filter Nested:
Use the And Filter to combine two or more filters. The And Filter accepts the message and returns true only if all of its enclosed filters return true.
The Or Filter returns true if any of its enclosed child filters return true. That is, it accepts the message if the message matches the criteria of any of its filters.
The Not Filter inverts its enclosed filter. That is, the Not Filter accepts the message and returns true if the message does not match the filter criteria. For example, if the enclosed filter normally returns true for a specific message, when nested within the Not filter it returns false.
Example Code
Code sample to create an And filter:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>
<and-filter name="And" doc:name="And">
<and-filter/>
</and-filter>
<flow name="add_logicFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<filter ref="And" doc:name="Filter Reference"/>
</flow>
</mule>