how to use expression filter

7
How to use Expression Filter

Upload: mdfkhan625

Post on 20-Feb-2017

172 views

Category:

Technology


0 download

TRANSCRIPT

How to use Expression Filter

Abstract

• The main motto of this PPT is how to use Expression filter in our applications.

Example

• .mflow• <?xml version="1.0" encoding="UTF-8"?>

• <mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:vm="http://www.mulesoft.org/schema/mule/vm" 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/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd• http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd• http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">• <flow name="MessagePropertiesFlow1" doc:name="MessagePropertiesFlow1">• <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8089" path="expressionfilter" doc:name="HTTP"/>• <message-properties-transformer scope="session" doc:name="Message Properties">• <add-message-property key="property1" value="mule studio"/>• </message-properties-transformer>• <logger message="--flow1--#[sessionVars['property1']]" level="INFO" doc:name="Logger"/>• <expression-filter expression="#[sessionVars['property1']!='mule']" doc:name="Expression"/>• <vm:outbound-endpoint exchange-pattern="request-response" path="messageproperties" doc:name="VM"/>• </flow>• <flow name="MessagePropertiesFlow2" doc:name="MessagePropertiesFlow2">• <vm:inbound-endpoint exchange-pattern="request-response" path="messageproperties" doc:name="VM"/>• <logger message="---flow2--#[sessionVars['property1']]" level="INFO" doc:name="Logger"/>• </flow>• </mule>

• Output:

• INFO 2015-10-03 16:00:23,705 [[messageproperties].config.change.14.thread.1] org.mule.DefaultMuleContext: • **********************************************************************• * Application: messageproperties *• * OS encoding: Cp1252, Mule encoding: UTF-8 *• * *• * Agents Running: *• * Clustering Agent *• * JMX Agent *• **********************************************************************• INFO 2015-10-03 16:00:23,706 [[messageproperties].config.change.14.thread.1]

org.mule.module.launcher.MuleDeploymentService: • ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++• + Started app 'messageproperties' +• ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++• INFO 2015-10-03 16:00:26,480 [[messageproperties].connector.http.mule.default.receiver.02]

org.mule.api.processor.LoggerMessageProcessor: --flow1--mule--studio• INFO 2015-10-03 16:00:26,482 [[messageproperties].connector.http.mule.default.receiver.02]

org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.VM.mule.default.dispatcher.771015974'. Object is: VMMessageDispatcher

• INFO 2015-10-03 16:00:26,482 [[messageproperties].connector.http.mule.default.receiver.02] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.VM.mule.default.dispatcher.771015974'. Object is: VMMessageDispatcher

• INFO 2015-10-03 16:00:26,489 [[messageproperties].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: ---flow2--mule--studio

• Flow of execution:1. URL to trigger the service from browser http://

localhost:8089/expressionfilter 2. session property is created using message property component In flow1 3. Service displays session properties in flow14. VM component in flow1 will call flow2 if the value of the session property is other then mule.5. In the POC the session property value is “mule studio” so flow1 calls flow2 and displays session property value in flow2