Home >> Miscellaneous
>> Mule-ESB-File-Transport
In this writeup I am going to walk you through the way I
started to use Mule as ESB. I am assuming that you have
prior knowledge of Java, Mule and ESB basics.
If you want to have basic understanding of Mule, before
starting to go through this article, I recommend/suggest
to go through the documentation from Mule website.
Mule website
->
http://www.mulesoft.com/
->
http://www.mulesoft.org/download-mule-esb-community-edition
->
http://www.mulesoft.com/esb-integration-resources
Mule as ESB has quite a large set of articles, documentation
available on some third party sites as well.
Other parties articles and documenation
->
http://today.java.net/pub/a/today/2007/07/31/exploring-esb-patterns-with-mule.html
->
http://www.devx.com/enterprise/Article/38115
->
http://www.javaworld.com/javaworld/jw-10-2009/091005-mule-cat.html
Once you have basic understanding of Mule and its various
functionalities, such as
What is a Endpoint?
What is a inbound/outbound endpoint?
What is a Router?
What is a Transport?
What is a Message?
What is a Transformation of Message?
What is a Component?
What is a Service?
Answer to all these questions from Mule specific point of
would make this example scenario much easier to uderstand.
As I shall try to touch upon all these points with respect
to some example code and not devote much time towards
explaination of all these questions.
In my understanding the very purpose of any ESB is to
provide a platform for de-coupling various external
applications to work seamlessly without worrying much
about impact of any additional application introduced
or updated, that is to be made part of the already running
set of integrated applications.
For example, suppose we have applications A, B, C are
all operated and interacted among one another, being
attached to some common protocol,
A B C
| | |
----------
----------
Now with addition of another application D, in the above
diagram should not mandate to look at already running
and integrated applications A, B, C as far as any change
is concerned.
A B C
| | |
----------
----------
|
D
So in my thinking in the above pictorial representation,
the parallel bars/dotted line can be represented by
Mule as ESB.
Suppose there is an application A that is writing a file
to some folder within a filesystem, and as soon as this
file is written onto the folder, another application D
is designed to receive this file from some another folder
from the same filesystem. This means both these applications
are having separate folders to work with.
Now how can these applications from this scenario be integrated
so that there should not be any change in code on either
applications.
I know this is a very very simplified example just to understand
how various pieces fit in here while using Mule as ESB.
So let us try to achieve a file movement functionality using
Mule, and this will provide a viable solution to the above
scenario requirement where application A puts a file in a
folder X , as soon as this file X is placed in the folder,
listener from Mule ESB will pickup the file and pass this
as message payload to another output folder Y, from this
folder application D is supposed to pick up this file
and do whatever it wants to do with this file.
Just not to deviate from the main objective of this example,
I shall only focus on the integration strategy as far as
Mule is concerned. So here I have to provide configuration
file to the Mule Framework and try to make Mule Framework
listen for a file in an input file folder and automatically
move any file that is placed in this input folder to another
file folder, that's it.
I started with the Mule standalone version 2.2.1 :
As per my understanding, I followed following steps
need not be the best way to setup Mule ESB, so please
refer Mule specific documentation/License before use:
Step 1:
Setup Mule Standalone version 2.2.1 from the Zipped
file from the Mule Download page:
Step 2:
Created a project folder structure as below,
Sample
|__ conf
| |___ [sample-config.xml]
|
|__ src
|___ source folder
As I don't have any component that can be configured
to be called in the process of this file transport
mechanism, so the src folder is blank as of now.
Step 3:
So the sample-config.xml file is the only configuration
file that I have to make this objective of file movement
achieved, wow.... so simple, isn't it!!!
Let us go through this sample-config.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:file="http://www.mulesource.org/schema/mule/file/2.2"
xsi:schemaLocation="
http://www.mulesource.org/schema/mule/core/2.2
http://www.mulesource.org/schema/mule/core/2.2/mule.xsd
http://www.mulesource.org/schema/mule/file/2.2
http://www.mulesource.org/schema/mule/file/2.2/mule-file.xsd">
<description>
This is my first example/sample using Mule
</description>
<model name="sampleExample">
<service name="sampleService">
<inbound>
<file:inbound-endpoint path="c:/test"/>
</inbound>
<outbound>
<!-- <pass-through-router>-->
<message-chunking-router>
<file:outbound-endpoint path="c:/test1"
outputPattern="\[ORIGINALNAME\]"/>
</message-chunking-router>
<!-- </pass-through-router> -->
</outbound>
</service>
</model>
</mule>
|
As you might have noticed above configuration, there is a
schema definition for the file (2.2) with appropriate XSD file.xsd.
We have got the model name as sampleExample, and service name as
sampleService. inbound is the file with endpoint as the path for
the directory (in this example it is c:/test, but it can be any folder
per se), and the outbound is another folder with the path as c:/test1
for this example. The outbound is having a message-chunking-router,
whereas a pass-through-router can be used instead.
Step 4 :
In order to run this example, I had to mention MULE_HOME
environment variable as the root folder of the Mule installation
local directory, and mention the sample-config.xml file as the
config parameter to the mule.bat file from the Mule installation
bin folder.
mule.bat -config <<file-folder-path>>/sample-config.xml
This is using the standalone version 2.2.1 of Mule.
Step 5:
Once the above process is runing successfully...
I just placed a dummy file in the input folder, just to observe
that this file is moved to the output folder automatically.
Hope this helps in whatsoever manner you think it works.
Please send in your suggestions/comments.
If anything missed out , please let me know at
techienjoy at yahoo . com
|
|
|
|
|
|
| Android Robots Example : |
Example using Borots using Android Platform
and source code implementing this example.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Android ListView Example : |
Example on Android ListView and
explained with a very simple scenario
and article with appropriate screens
captured and shown.
|
|
|
|
|
|
|
|
|
|
| Android Gallery Example : |
Example on Android Gallery View
explained with a very simple scenario
and appropriate screens captured and shown.
|
|
|
|
|
| Android ListView Example : |
Example on Android ListView
explained with a very simple scenario
whereby showing folder and files with
structure and appropriate screens
captured and shown.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Android NFC Example : |
Example using NFC using Android Platform
and source code implementing this example.
|
|
|
|
|
| Android Sensors Example : |
Example on Android Sensors Listed and
explained with a very simple scenario
and article with appropriate screens
captured and shown.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Android GridView Example : |
Example using GridView Widget using Android Platform
and source code implementing this example.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Android Views Example : |
Example using Views using Android Platform
and source code implementing this example.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Android Intent Example : |
Example using Intent from Android Platform
and source code implementing this example.
|
|
|
|
|
|
| Android Canvas Example : |
Example using Canvas using Android Platform
and source code implementing this example.
|
|
|
| Android Tab View Example : |
Example on Android Tab View
explained with a very simple scenario
and appropriate screens captured and shown.
|
|
|
|
|
|
| Android ListView Example : |
Example on Android List View
explained with a very simple scenario
and article with appropriate screens
captured and shown.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Android Draw Example : |
Example using Draw using Android Platform
and source code implementing this example.
|
|
|
|
|
| Google GWT Example : |
Example using GWT and some design patterns and various
ways of implementing this example.
|
|
|
|
| Android Examples : |
List of ANDROid examples
with source code and output
screens captured and shown.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|