Expression Transformer in Mule

Expression Transformer in Mule

Expression transformer evaluates one or more expressions and return true if input matches with expression otherwise false.

An Expression Transformer evaluates one or more expressions on the current message. Each evaluated expression equates to a parameter in the returned message. However, if the returned message encompasses more than one expression, then the results of those expressions are an Object array.The Expression Transformer has the same advanced properties as all other transformers with the addition of an optional list of return arguments.

flow of expression transformer :

expression given in expression transformer :
 #[message.inboundProperties.'http.query.params'.name == 'himanshu']

output will be true if query parameter in input is name=himanshu

URL : http://localhost:8085/api/exptransformer

Method : GET

Input :

hit the url : http://localhost:8085/api/exptransformer?name=himanshu

Output :

XML project code :

<?xml version="1.0" encoding="UTF-8"?> <mule xmlns:http="" xmlns="" xmlns:doc="" xmlns:spring="" xmlns:xsi="" xsi:schemaLocation=""> <http:listener-config name="HTTP_Listener_Configuration" host="" port="8085" basePath="/api" doc:name="HTTP Listener Configuration"/> <flow name="test_expressiontransformerFlow"> <http:listener config-ref="HTTP_Listener_Configuration" path="/exptransformer" doc:name="HTTP"/> <expression-transformer expression="#[message.inboundProperties.'http.query.params'.name == 'himanshu']" doc:name="Expression"/> <object-to-string-transformer doc:name="Object to String"/> </flow> </mule>