twitter connectorfor multiple user configuration in mulesoft - mule

In Mulesoft, How can I manage multiple twitter user accounts dynamically because at present it requires consumerkey, consumersecret, accesskey and accesstoken in connector configuration for an application which can own only one user.
Please anyone can explain?
<twitter:config name="Twitter__Configuration" accessKey="#[flowVars.accessToken]" consumerKey="#[flowVars.consumerKey]" consumerSecret="#[flowVars.consumerSecret]" doc:name="Twitter: Configuration" accessSecret="#[flowVars.accessTokenSecret]"/>
<flow name="twitterFlow1">
<db:select config-ref="MySQL_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[select * from twittercredentials;]]></db:parameterized-query>
</db:select>
<set-variable variableName="consumerKey" value="#[message.payload[0]['consumerkey']]" doc:name="Variable" />
<set-variable variableName="consumerSecret" value="#[message.payload[0]['consumersecret']]" doc:name="Variable" />
<set-variable variableName="accessToken" value="#[message.payload[0]['accesstoken']]" doc:name="Variable" />
<set-variable variableName="accessTokenSecret" value="#[message.payload[0]['accesstokensecret']]" doc:name="Variable" />
</flow>
<flow name="twitterFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/twitterconnect" doc:name="HTTP"/>
<flow-ref name="twitterFlow1" />
<twitter:show-user config-ref="Twitter__Configuration" doc:name="Twitter"/>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
assigned the values in variables and accessed as flowvars in the global element which fails.

I think in this post from mule community forum you can find the answer to your question.
Basically you can use mule expression language in twitter globalk connector in this way:
<twitter:config name="Twitter" accessKey="#[flowVars.accessKey]"
accessSecret="#[flowVars.accessSecret]" consumerKey="#
[flowVars.consumerKey]" consumerSecret="#[flowVars.consumerSecret]"/>
Hope this helps
Full example:
This is an example flow:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:twitter="http://www.mulesoft.org/schema/mule/twitter" 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://www.mulesoft.org/schema/mule/twitter http://www.mulesoft.org/schema/mule/twitter/current/mule-twitter.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<twitter:config name="Twitter" accessKey="#[flowVars['accessKey']]" accessSecret="#[flowVars['accessSecret']]" consumerKey="Cannot be parametrized" consumerSecret="Cannot be parametrized" useSSL="false" doc:name="Twitter"/>
<flow name="twitterFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/test" doc:name="HTTP"/>
<logger level="INFO" doc:name="Logger"/>
<message-properties-transformer scope="invocation" doc:name="Message Properties">
<add-message-property key="accessKey" value="#['myVarAccessKey']"/>
<add-message-property key="accessSecret" value="#['myVarAccessSecret']"/>
</message-properties-transformer>
<twitter:update-status config-ref="Twitter" status="ciao" doc:name="Twitter"/>
</flow>
</mule>
Here also a screenshot of a wireshark capture using IP filtering (twitter ip families) for debug the http call:

Related

How to add multiple http request calls in foreach | Mule 3

I am using scatter-gather to call many endpoints with the same host and different paths. How can I add the HTTP request connector inside For Each scope, that can loop into the different paths and add the payload to the same file?
My code is as below, I would like to loop over the HTTP request;
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:ftp="http://www.mulesoft.org/schema/mule/ee/ftp" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw"
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.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
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/ee/ftp http://www.mulesoft.org/schema/mule/ee/ftp/current/mule-ftp-ee.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<http:request-config name="HTTP_Request_Configuration-testt" protocol="HTTPS" host="servicenow.com" port="443" doc:name="HTTP Request Configuration"/>
<http:listener-config name="HTTP_Listener_Configuration1" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="servicenow-call">
<http:listener config-ref="HTTP_Listener_Configuration1" path="/test" doc:name="HTTP"/>
<scatter-gather doc:name="Scatter-Gather">
<http:request config-ref="HTTP_Request_Configuration-testt" path="/repo/cat1" method="GET" doc:name="HTTP Request 1"/>
<http:request config-ref="HTTP_Request_Configuration-testt" path="/repo/cat2" method="GET" doc:name="HTTP Request 2"/>
<http:request config-ref="HTTP_Request_Configuration-testt" path="/repo/cat3"" method="GET" doc:name="HTTP Request 4"/>
</scatter-gather>
<dw:transform-message doc:name="Set JSON">
<dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
payload]]></dw:set-payload>
</dw:transform-message>
<file:outbound-endpoint path="D:\Local\NewFile.json" outputPattern="first-#[function:datestamp:ddMMyyyy-HHmmss].json" responseTimeout="10000" doc:name="Write FIle"/>
<exception-strategy ref="ImplementationChoice_Exception_Strategy" doc:name="Reference Exception Strategy"/>
</flow>
</mule>
Check the below sample code how we can use foreach in your scenario. THis is in Mule4. I hope you can do it in Mule3 as well.
I am not sure why you want to use foreach. I would suggest use Scatter_Gather instead of foreach. Because foreach will work sequentially and Scatter_Gather works concurrently. Performance wise concurrent process is good.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" 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:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="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://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<flow name="Testing_foreach_stackoverflowFlow" doc:id="95fe6a04-4aca-4106-a0b3-b53afb7be95a" >
<scheduler doc:name="Scheduler" doc:id="e6a81b1c-43f9-486a-a451-b31bcadbe23f" >
<scheduling-strategy >
<fixed-frequency frequency="5" timeUnit="MINUTES"/>
</scheduling-strategy>
</scheduler>
<set-variable value="#[%dw 2.0
output application/json
---
[]]" doc:name="Set Variable" doc:id="7b1bbba6-d63d-4f89-905b-8b9c7d6a7555" variableName="result"/>
<set-payload value='#[["test1","test2"]]' doc:name="Set Payload" doc:id="1b7ff757-1a42-4291-b759-50632db842d3" />
<foreach doc:name="For Each" doc:id="2010c075-b487-4977-8a34-0f58adb23a7d" >
<http:request method="GET" doc:name="Request" doc:id="a0524fe5-2344-46c2-bb03-90660fb8fc04" url='#["http://localhost:8091/" ++ payload]'/>
<ee:transform doc:name="Transform Message" doc:id="0aca9608-f7a1-4e1a-a246-11830b6f245e" >
<ee:message >
</ee:message>
<ee:variables >
<ee:set-variable variableName="result" ><![CDATA[%dw 2.0
output application/json
---
vars.result + payload
]]></ee:set-variable>
</ee:variables>
</ee:transform>
<logger level="INFO" doc:name="payload" doc:id="22bc3348-90f9-4290-bb53-ee4c19af1f18" message="#[payload]"/>
</foreach>
<logger level="INFO" doc:name="payload" doc:id="00e70062-6898-42d7-bc50-974f23a4cd93" message="#[payload]"/>
</flow>
<flow name="Testing_foreach_stackoverflowFlow1" doc:id="fc055a5c-09a0-4dce-99be-70e863ffb0ff" >
<http:listener doc:name="Listener" doc:id="298d5fff-c712-4307-895a-7d4faac42eb1" config-ref="api-httpListenerConfig" path="/test1"/>
<set-payload value='"grapes"' doc:name="Set Payload" doc:id="bfce761e-c63a-4a06-ab9b-f17360d9a7d2" />
</flow>
<flow name="Testing_foreach_stackoverflowFlow2" doc:id="12d67768-525e-46b0-91b4-ce9377b0b7d1" >
<http:listener doc:name="Listener" doc:id="24fc80d9-0f93-4217-a1a2-3802b57ce3cb" config-ref="api-httpListenerConfig" path="/test2"/>
<set-payload value='"banana"' doc:name="Set Payload" doc:id="01ad0e82-5f50-49a3-9804-10190953b1c0" />
</flow>
</mule>
Set a variable with an empty list before the foreach, and for each iteration concatenate the results. I guess you can set a list of the paths and use it to iterate the foreach.

Mule 3.8.3 Runtime - Database connector - using query from flow variable returns java.lang.IllegalArgumentException

I'm not able to refer the query from flowVariable inside database connector. I have read that it was a known issue in mule 3.5. I'm not sure if it is still an open issue in 3.8. Do any one know about it ?
Below is the flow -
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:db="http://www.mulesoft.org/schema/mule/db" 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://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<db:mysql-config name="MySQL_Configuration5" host="localhost" port="3306" user="root" password="root" database="world" doc:name="MySQL Configuration"/>
<flow name="selectFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/db/select" allowedMethods="GET" doc:name="HTTP"/>
<db:select config-ref="MySQL_Configuration5" doc:name="local mysql database">
<db:parameterized-query><![CDATA[select * from country where code='IND']]></db:parameterized-query>
</db:select>
<json:object-to-json-transformer doc:name="Object to JSON"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>
<flow name="deleteFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/db/delete" allowedMethods="DELETE" doc:name="HTTP"/>
<db:delete config-ref="MySQL_Configuration5" doc:name="local mysql database">
<db:parameterized-query><![CDATA[delete from countrylanguage where countrycode='PAK']]></db:parameterized-query>
</db:delete>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
<flow name="postFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/db/insert" allowedMethods="POST" doc:name="HTTP"/>
<set-variable variableName="jsonString" value="#[payload]" doc:name="Variable"/>
<flow-ref name="cleanUpBeforeInserting" doc:name="cleanUpBeforeInserting"/>
<json:json-to-object-transformer doc:name="JSON to Object" returnClass="java.util.Collection"/>
<flow-ref name="InsertEachRecord" doc:name="Flow Reference"/>
</flow>
<flow name="cleanUpBeforeInserting">
<db:delete config-ref="MySQL_Configuration5" doc:name="Database">
<db:parameterized-query><![CDATA[delete from countrylanguage where countrycode='PAK']]></db:parameterized-query>
</db:delete>
<set-payload value="#[flowVars.jsonString]" doc:name="Set Payload"/>
<logger message="************* cleaned up data **************** " level="INFO" doc:name="Logger"/>
</flow>
<sub-flow name="InsertEachRecord">
<foreach doc:name="For Each">
<set-variable variableName="sqlStatement" value="Insert into countrylanguage (countrycode, language, percentage, isofficial) values(#[payload.CountryCode], #[payload.Language],#[payload.Percentage], #[payload.IsOfficial])" doc:name="Variable"/>
<logger message="#[flowVars.sqlStatement]" level="INFO" doc:name="Logger"/>
<db:insert config-ref="MySQL_Configuration5" doc:name="Database">
<db:parameterized-query><![CDATA[#[flowVars.sqlStatement]]]></db:parameterized-query>
</db:insert>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</foreach>
</sub-flow>
</mule>
It works fine if I replace the #[flowVars.sqlStatement] with Insert into countrylanguage (countrycode, language, percentage, isofficial) values(#[payload.CountryCode], #[payload.Language],#[payload.Percentage], #[payload.IsOfficial])
Any pointers would be helpful. Thanks in advance.
Instead using <db:parameterized-query> try with <db:dynamic-query> like following
<db:insert config-ref="MySQL_Configuration5" doc:name="Database">
<db:dynamic-query><![CDATA[#[flowVars.sqlStatement]]]></db:dynamic-query>
</db:insert>

How to Implement Parallel Processing of Message in Mule using VM and Request-Reply Scope

Hi i am working with Mule Any Point Studio and i am curious to know about how this works with VM and Request-Reply scope so that Mule is able to asynchronously process the multiple incoming calls to Mule.
I just want to know how Request-Reply scope works internally. I have gone through complete Mule Tutorial as mention in the given link. But i didn't get the correct idea of working , i am new bee to this.
Request-Reply Scope:
I want to use Request-Reply Scope to implement the Async Parallel Processing with Mule using VM.
For this i went through with this Link but still i need more light on how this works.
Blog:
Here I tried and got the answer of my question with code please have a look at this , i am printing Thread ID that will give clear picture how its working.
<?xml version="1.0" encoding="UTF-8" ?>
<mule xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:ws="http://www.mulesoft.org/schema/mule/ws" xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
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.5.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
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.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/ws http://www.mulesoft.org/schema/mule/ws/current/mule-ws.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
<flow name="mule-request-replyFlow1" doc:name="mule-request-replyFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="rr" doc:name="HTTP" />
<request-reply doc:name="Request-Reply">
<vm:outbound-endpoint exchange-pattern="one-way" path="req" doc:name="VM" />
<vm:inbound-endpoint exchange-pattern="one-way" path="res" doc:name="VM" />
</request-reply>
<logger message=" Message payload after Outbound #[message.payload] and Thread is #[Thread.currentThread().getName()] and Thread ID is #[Thread.currentThread().getId()]" level="INFO" doc:name="Logger" />
<object-to-string-transformer doc:name="Object to String" />
</flow>
<flow name="mule-request-replyFlow3" doc:name="mule-request-replyFlow3">
<vm:inbound-endpoint exchange-pattern="one-way" path="req" doc:name="VM" />
<http:outbound-endpoint exchange-pattern="request-response" method="GET" address="http://localhost/service/orderservice" doc:name="HTTP" />
<object-to-string-transformer doc:name="Object to String" />
<logger message="Response Handler Payload is #[message.payload] and Thread ID is #[Thread.currentThread().getId()]" level="INFO" doc:name="Logger" />
<vm:outbound-endpoint exchange-pattern="one-way" path="res" doc:name="VM" />
</flow>
</mule>
The request-reply is just sending the received message to the request endpoint, and then blocking the current thread until a message arrives to the reply endpoint with a correlation id that matches the correlation id that was sent to the request endpoint.
We can summarize it as a synchronous emulator for asynchonous endpoints. In the example you give, you could probably simplify the same leveraging the mule reply to header.

Making call to Rest services in mule ESB

I have made a web app which call mule server which is listening to http inbound point at 8081 for accessing the database.I am accessing the database successfully and getting a message. But I want to access the other rest services after I get the object from the database and run some operations.
I don't know how to achieve this.
Please give me example. I am posting my flow.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns:jersey="http://www.mulesoft.org/schema/mule/jersey" xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" 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.5.1"
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://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/jersey http://www.mulesoft.org/schema/mule/jersey/current/mule-jersey.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
<http:endpoint exchange-pattern="request-response" host="localhost" port="8081" method="POST" name="HTTP" doc:name="HTTP"/>
<db:mysql-config name="MySQL_Configuration" host="localhost" port="3306" user="root" password="123456" database="Customer" doc:name="MySQL Configuration"/>
<flow name="muleesbintegrationFlow1" doc:name="muleesbintegrationFlow1">
<http:inbound-endpoint exchange-pattern="request-response" path="crud" doc:name="HTTP" ref="HTTP"/>
<set-session-variable variableName="input" value="#[message.inboundProperties.'http.query.params'.input]" doc:name="input"/>
<set-session-variable variableName="cid" value="#[message.inboundProperties.'http.query.params'.cid]" doc:name="cid"/>
<set-session-variable variableName="fname" value="#[message.inboundProperties.'http.query.params'.fname]" doc:name="fname"/>
<set-session-variable variableName="lname" value="#[message.inboundProperties.'http.query.params'.fname]" doc:name="lname"/>
<choice doc:name="ChoicerOfCrud">
<when expression="#[sessionVars['input']== "insert"]">
<db:insert config-ref="MySQL_Configuration" doc:name="insert">
<db:parameterized-query><![CDATA[INSERT INTO `Customer`.`customer` (`customer_id`, `fname`, `lname`) VALUES (#[sessionVars['cid']], #[sessionVars['fname']], #[sessionVars['lname']]);]]></db:parameterized-query>
</db:insert>
</when>
<when expression="#[sessionVars['input']]=="update"]">
<db:update config-ref="MySQL_Configuration" doc:name="update">
<db:parameterized-query><![CDATA[UPDATE `Customer`.`customer` set
fname = #[sessionVars['fname']],
lname= #[sessionVars['lname']]
where customer_id = #[sessionVars['cid']];]]></db:parameterized-query>
</db:update>
</when>
<when expression="#[sessionVars['input']=="select"]">
<db:select config-ref="MySQL_Configuration" doc:name="selected">
<db:parameterized-query><![CDATA[SELECT * FROM Customer.customer where customer_id =#[sessionVars['cid']];]]></db:parameterized-query>
</db:select>
</when>
<otherwise>
<db:delete config-ref="MySQL_Configuration" doc:name="delete">
<db:dynamic-query><![CDATA[DELETE FROM `Customer`.`customer` WHERE `customer_id`=#[sessionVars['cid']];]]></db:dynamic-query>
</db:delete>
</otherwise>
</choice>
</flow>
</mule>
I recommend to use http:outbound-endpoint to consume a REST service (GET,POST, PUT or DELETE). In this example you can see a flow to invoke a services GET:
<flow name="invoke-ws" doc:name="invoke-ws">
<vm:inbound-endpoint exchange-pattern="request-response" path="vm-ws" doc:name="VM"/>
<logger message="payload is: #[payload]" level="INFO" doc:name="Logger"/>
<http:outbound-endpoint exchange-pattern="request-response" method="GET" address="http://ip:port/service/#[payload]" doc:name="HTTP">
<set-property propertyName="Accept" value="application/json"/>
</http:outbound-endpoint>
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
<logger message="payload is: #[payload]" level="INFO" doc:name="Logger"/>
</flow>
If the service is SOAP over HTTP, I recommend using http://www.mulesoft.org/documentation/display/current/Web+Service+Consumer

Integer Comparision in mule choice component

I have a very simple flow where im trying to do comparision of inbound property and payload which are integers inside a choice component, inspite of the values being the same the choice component routes its to the default section.
I would like to get some help to make this work
Thank you in advance
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" 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
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<flow name="flow_testFlow1" doc:name="flow_testFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
<set-payload value="#[12]" doc:name="Set Payload"/>
<set-property propertyName="trial" value="#[12]" doc:name="Property"/>
<choice doc:name="Choice">
<when expression="#[payload == message.inboundProperties['trial']]">
<logger level="INFO" doc:name="Logger" message="Success"/>
</when>
<otherwise>
<logger level="INFO" doc:name="Logger" message="error"/>
</otherwise>
</choice>
</flow>
</mule>
set-property sets properties in the outbound scope, the inbound scope is read-only (created by the inbound endpoint).
So you need to fix your choice route expression like this:
<when expression="#[payload == message.outboundProperties['trial']]">
And then it works.