In this walk through, I would build a mule flow which would receive a booking request and mule flow would to invoke Cab Booking web service and archive the message to database and finally fetch available cars from DB using scatter gather pattern.
As usual we will configure configure HTTP Connector with listener configuration as shown,
Lets bring in as web service consumer connector and add a new connector configuration as shown and choose the relevant operation from the dropdown.Web service expects specify format as its request, to achieve it bring a transform message and set the payload at the source and apply the logic as shown
Lets run the project and post the Booking Request message, the web service response is echoed back
Add new transform message and apply the mapping logic after the service call
Retest the mule application.
Now lets try to archive the message we receive to a Database table, extract the cab booking flow into a subflow and then drag and drop the scatter-gather router and move cab booking flow reference into it
Bring in database connector into the scatter-gather router and configure the connector properties as shown.
Re-run the application, this would process the message but still an exception is thrown. This is because multiple message/payload isn't handled properly.
Bring in a transform message after the logger and access payload with indices as shown would resolve the issue
Test the application by posting a booking request. Successful response is received.
Lets add another Database connector to the scatter-gather router and perform a simple select from cars table and tranform to an XML format as shown. In the finally transformation, add logic to map the cars data to the final response.
Re-test the application.
Built a new mule flow for Hotel booking as shown below, its mock kind of flow where a request is received and mock success response is rendered to client using payload and property activities. Similarly develop another flow for Flight booking. These are mock services, that would be invoked using scatter gather.
Here is the main flow that uses scatter gather router to call Hotel and Flight Booking using HTTP Connectors. If you noticed the main different between earlier and the current one, payload isn't passed to child flows and hence payload conversion from object to byte array is not used.Run the project and test the application
No comments:
Post a Comment
Note: only a member of this blog may post a comment.