You can try it in the following way using java transformer component. It's working for me.
Below is the main mule xml config file
<?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="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="tryoutFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/bill" allowedMethods="GET" doc:name="HTTP"/>
<set-variable variableName="var1" value="#[message.inboundProperties.'http.query.params'.value1]" doc:name="var1"/>
<set-variable variableName="var2" value="#[message.inboundProperties.'http.query.params'.value2]" doc:name="var2"/>
<custom-transformer class="org.mule.transformar.Addition" returnClass="java.lang.Integer doc:name="Java">
</custom-transformer>
</flow>
</mule>
And below are the java class which java transformer component use to transform your message. Remember put the java class under src/main/java folder.
org.mule.transformar.Addition
package org.mule.transformar;
import org.mule.api.MuleMessage;
import org.mule.api.transformer.TransformerException;
import org.mule.api.transport.PropertyScope;
import org.mule.transformer.AbstractMessageTransformer;
public class Addition extends AbstractMessageTransformer{
@Override
public Integer transformMessage(MuleMessage message, String outputEncoding) throws TransformerException {
// TODO Auto-generated method stub
Integer i1 = Integer.parseInt(message.getProperty("var1", PropertyScope.INVOCATION));
Integer i2 = Integer.parseInt(message.getProperty("var2", PropertyScope.INVOCATION));
Integer returnVal = i1 + i2;
return returnVal;
}
}