Embedding Mule in a Webapp
 | This page is ready for review |
To embed Mule inside your webapp, you provide one or more configuration file locations as context params and include a context listener to initialize the Mule Server. For example:
<context-param>
<param-name>org.mule.config</param-name>
<param-value>mule-config-main.xml,mule-components.xml</param-value>
</context-param>
<listener>
<listener-class>org.mule.config.builders.MuleXmlBuilderContextListener</listener-class>
</listener>
The configuration param can either be a classpath location of file location. You can also specify multiple configuration files, which can be on the classpath or on the file system.
To interact with the Mule server from your JSPs or servlets, you can use the [Mule Client].
MuleClient client = new MuleClient();
client.dispatch("jms:, "some data", null);
MuleMessage message = client.receive("pop3:, 3000);
MuleMessage message2 = client.send("vm:, "Some more data", null);