Hello World Example
This page describes the configuration and behavior of the Hello world example provided with the Mule distribution. This sample uses two services to create a "hello world" message. When the sample starts, it prompts you to type your name, which is received by the first service. The service component adds some text to the string before passing it on to the second service, which also adds text before writing the results back to the console. There are easier ways to achieve this same result, but this example provides a nice demonstration of how a message flows in a Mule application.

Running the Application
- Make sure you have met the prerequisites and installed Mule according to the Installing Mule instructions.
- At the command line, navigate to the examples/hello directory under your Mule home directory.
- Type hello.bat on Windows or ./hello on UNIX.
- Follow the on-screen prompts. If you choose the simple configuration, you will be prompted to enter your name. If you choose to receive events via HTTP, you can invoke the service by pointing your browser to http://localhost:8888?name=yourName.
- To stop Mule, type 'CTRL-C' in the Mule console window.
How it Works
There are two services configured in the Hello world example:
- GreeterUMO - Receives the name the user enters and prepends "Hello".
- ChitChatUMO - Receives the Hello message from GreeterUMO and appends ", How are you?" to the string.
The GreeterUMO service is configured in the hello-config.xml file in examples/hello/conf under your Mule home directory. Services are defined using the <service> element, and are configured as follows:
<service name="GreeterUMO">
<inbound>
<stdio:inbound-endpoint system="IN" transformer-refs="StdinToNameString"/>
</inbound>
<component class="org.mule.example.hello.Greeter"/>
<outbound>
<filtering-router>
<vm:outbound-endpoint path="chitchatter"/>
<payload-type-filter expectedType="org.mule.example.hello.NameString"/>
</filtering-router>
<filtering-router>
<vm:outbound-endpoint path="userErrorHandler"/>
<payload-type-filter expectedType="java.lang.Exception"/>
</filtering-router>
</outbound>
<default-service-exception-strategy>
<vm:outbound-endpoint path="systemErrorHandler"/>
</default-service-exception-strategy>
</service>
The <inbound-endpoint> element receives inbound messages for the GreeterUMO component using the STDIO transport. The transformer-refs property specifies the inbound transformer to invoke before the GreeterUMO receives the message. In this case, the transformer converts the String it receives from the STDIO transport into a NameString object, which is the data type expected by the GreeterUMO component. The only purpose of doing this in the example is to demonstrate how Mule will discover which method to invoke in the GreeterUMO component based on the transformer configured on it. This transformer is defined earlier in the configuration file as follows:
<custom-transformer name="StdinToNameString" class="org.mule.example.hello.StdinToNameString"/>
After the GreeterUMO component has been invoked, Mule dispatches the message on the endpoint vm://chitchatter. This sends the message to an in-memory queue called chitchatter.
The GreeterUMO service also specifies some exception handlers to handle user errors and system errors. These are defined as services later in the configuration file.
After the GreeterUMO service has prepended "Hello" to the input user name, the ChitChatUMO service appends its text to the message. Its configuration looks like this:
<service name="ChitChatUMO">
<inbound>
<vm:inbound-endpoint path="chitchatter" transformer-refs="NameStringToChatString"/>
</inbound>
<component class="org.mule.example.hello.ChitChatter"/>
<outbound>
<outbound-pass-through-router>
<stdio:outbound-endpoint system="OUT" transformer-refs="ChatStringToString" />
</outbound-pass-through-router>
</outbound>
</service>
To demonstrate transformers further, the ChitChatUMO component expects a ChatString, so we have a NameStringToChatString transformer that converts the message's payload from the NameString to a ChatString before the component receives the message. The message is received on vm://chitchatter, the endpoint on which the GreeterUMO dispatched its message.
After processing the message, the message is sent on the STDIO endpoint System.out. There is one more transformer, ChatStringToString, that converts the payload from a ChatString to a plain string so that it can be handled by the STDIO transport and displayed in the console as follows: