 The main motto of this PPT is How to use Or
Filter in our applications.
 Mule bundles more than a dozen Filters that
determine whether a message can proceed
through an application flow. The simplest
filters implement basic logic operators (such
as and, or, and not), but these simple
elements can be combined in various ways to
specify complex logical conditions.
.mflow
<?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" version="EE-3.4.0"
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">
<flow name="OrFilterFlow1" doc:name="OrFilterFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8090" path="OrFilter"
doc:name="HTTP"/>
<logger message="----entered into the flow" level="INFO" doc:name="Logger"/>
<set-payload value="&lt;Soap-Env&gt;&lt;Body&gt;&lt;Path&gt;mule&lt;/Path&gt;&lt;/Body&gt;&lt;/Soap-
Env&gt;" doc:name="Set Payload"/>
<or-filter doc:name="Or">
<expression-filter expression="#[xpath('/Soap-Env/Body/Path/text()').text.contains('mule')]"/>
<expression-filter expression="#[xpath('/Soap-Env/Body/Path/text()').text.contains('soft')]"/>
</or-filter>
<logger message="--Success" level="INFO" doc:name="Logger"/>
</flow>
</mule>
 Output:
INFO 2015-12-12 07:03:26,157 [main] org.mule.DefaultMuleContext:
**********************************************************************
* Application: OrFilter *
* OS encoding: Cp1252, Mule encoding: UTF-8 *
* *
* Agents Running: *
* Clustering Agent *
* JMX Agent *
**********************************************************************
INFO 2015-12-12 07:03:26,158 [main]
org.mule.module.launcher.MuleDeploymentService:
+++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++
+ Started app 'OrFilter' +
+++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++
INFO 2015-12-12 07:03:54,738 [[OrFilter].connector.http.mule.default.receiver.02]
org.mule.api.processor.LoggerMessageProcessor: ----entered into the flow
INFO 2015-12-12 07:03:54,994 [[OrFilter].connector.http.mule.default.receiver.02]
org.mule.api.processor.LoggerMessageProcessor: --Success
 Flow of execution:
1. URL to trigger the service from browser
http://localhost:8090/OrFilter
2. OR filter checks whether the request contains
‘mule’ or ‘soft’ or not?, if yes, it will print a
message ‘Success’, else it will not go further.
 https://docs.mulesoft.com/mule-user-
guide/v/3.7/filters

Or Filter

  • 2.
     The mainmotto of this PPT is How to use Or Filter in our applications.
  • 3.
     Mule bundlesmore than a dozen Filters that determine whether a message can proceed through an application flow. The simplest filters implement basic logic operators (such as and, or, and not), but these simple elements can be combined in various ways to specify complex logical conditions.
  • 5.
    .mflow <?xml version="1.0" encoding="UTF-8"?> <mulexmlns: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" version="EE-3.4.0" 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"> <flow name="OrFilterFlow1" doc:name="OrFilterFlow1"> <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8090" path="OrFilter" doc:name="HTTP"/> <logger message="----entered into the flow" level="INFO" doc:name="Logger"/> <set-payload value="&lt;Soap-Env&gt;&lt;Body&gt;&lt;Path&gt;mule&lt;/Path&gt;&lt;/Body&gt;&lt;/Soap- Env&gt;" doc:name="Set Payload"/> <or-filter doc:name="Or"> <expression-filter expression="#[xpath('/Soap-Env/Body/Path/text()').text.contains('mule')]"/> <expression-filter expression="#[xpath('/Soap-Env/Body/Path/text()').text.contains('soft')]"/> </or-filter> <logger message="--Success" level="INFO" doc:name="Logger"/> </flow> </mule>
  • 6.
     Output: INFO 2015-12-1207:03:26,157 [main] org.mule.DefaultMuleContext: ********************************************************************** * Application: OrFilter * * OS encoding: Cp1252, Mule encoding: UTF-8 * * * * Agents Running: * * Clustering Agent * * JMX Agent * ********************************************************************** INFO 2015-12-12 07:03:26,158 [main] org.mule.module.launcher.MuleDeploymentService: +++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++ + Started app 'OrFilter' + +++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++ INFO 2015-12-12 07:03:54,738 [[OrFilter].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: ----entered into the flow INFO 2015-12-12 07:03:54,994 [[OrFilter].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: --Success
  • 7.
     Flow ofexecution: 1. URL to trigger the service from browser http://localhost:8090/OrFilter 2. OR filter checks whether the request contains ‘mule’ or ‘soft’ or not?, if yes, it will print a message ‘Success’, else it will not go further.
  • 8.