or filter
TRANSCRIPT
Or Filter
The main motto of this PPT is How to use Or Filter in our applications.
Abstract
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.
Introduction
Example
.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.xsdhttp://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsdhttp://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="<Soap-Env><Body><Path>mule</Path></Body></Soap-Env>" 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 flowINFO 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 browserhttp://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
References