mule requesterdemo part 2

10
By Anirban Sen Chowdhary

Upload: anirban-sen-chowdhary

Post on 22-Jul-2015

113 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Mule requesterdemo part 2

By Anirban Sen Chowdhary

Page 2: Mule requesterdemo part 2

.

Page 3: Mule requesterdemo part 2

.

Page 4: Mule requesterdemo part 2

Let me introduce you a component in Mule called Mule Requester

Mule Requester

This component we can place in between our Mule flow and can be used for any Inbound component like Http, JMS or File

Page 5: Mule requesterdemo part 2

It can :-• Load a file in a middle of a flow and start processing it.• call a JMS queue and fetch the data from it in middle of

a queue• Pull messages from a mail server on demand

Page 6: Mule requesterdemo part 2

Let us consider we need to fetch a file from a folder and read the content in the middle of the flow and move the file to another folder

So you can see we have put a Mule requester in the middle of the flow which will act as an file inbound endpoint here

Page 7: Mule requesterdemo part 2

Now the corresponding Mule flow will be following :-

<flow name="serviceFlow" doc:name="serviceFlow"><http:inbound-endpoint exchange-pattern="request-response"

host="localhost" port="8081" path="requestfile" doc:name="HTTP" contentType="text/xml"

mimeType="text/xml" /><set-payload value="'Started Processing'" doc:name="Set Payload" />

<mulerequester:request config-ref="Mule_Requester" resource="file:///E:/backup/test/test.txt" returnClass="java.lang.String" doc:name="Request a file"/><file:outbound-endpoint path="E:\backup\test\newfolderoutputPattern="#[message.inboundProperties.originalFilename]" responseTimeout="10000" doc:name="File"/>

</flow>

As you can see above the Mule requestor is placed after Http inbound endpoint so that after we hit the url http://localhost:8081/requestfile in browser it will work. It will read file test.txt and put it in the folder :E:\backup\test\newfolder

Page 8: Mule requesterdemo part 2

Now if we hit the url :- http://localhost:8081/requestfile , we will see in our Mule console the following :-

You can see here the file test.txt has bee dispatched to it’s destination location

Page 9: Mule requesterdemo part 2

Thus, with the help of Mule Requester we can call any inbound endpoint in Mule in between the Mule flow starting from JMS, to http inbound and even File inbound. And the example has shown you that we can use this Mule Requester as a file inbound endpoint and can be used in the middle of a Mule flow

Page 10: Mule requesterdemo part 2