Skip navigation

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].

//create a client
MuleClient client = new MuleClient();

//send a JMS message asynchronously
client.dispatch("jms://my.queue", "some data", null);

//or to receive a pop3 message via a configured mailbox
MuleMessage message = client.receive("pop3://ross:secret@mail.mycompany.com", 3000);

//or synchonous send a inter-vm message
MuleMessage message2 = client.send("vm://my.object", "Some more data", null);
Adaptavist Theme Builder Powered by Atlassian Confluence