Mule JBoss JMS Integration
Mule is not a JMS provider. Mule can use the queues and topics from a JMS provider like JBOSS easily. The following example provides a simple configuration to use the JBoss JMS Queue in Mule.
1. Configuring your pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.mybusiness</groupId>
<artifactId>MuleTutorial</artifactId>
<version>1.0</version>
<repositories>
<repository>
<id>MuleRepo</id>
<name>Mule Repository</name>
<url>http://repository.muleforge.org/</url>
<layout>default</layout>
<releases>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>codehaus-repo</id>
<name>Codehaus Repository</name>
<url>http://dist.codehaus.org/mule/dependencies/maven2</url>
<layout>default</layout>
<releases>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group </name>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.mule</groupId>
<artifactId>mule-core</artifactId>
<version>2.2.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-vm</artifactId>
<version>2.2.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-stdio</artifactId>
<version>2.2.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-jms</artifactId>
<version>2.2.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-file</artifactId>
<version>2.2.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-jbossts</artifactId>
<version>2.2.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-management</artifactId>
<version>2.2.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-http</artifactId>
<version>2.2.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jboss</groupId>
<artifactId>jbossall-client</artifactId>
<version>3.2.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jboss</groupId>
<artifactId>jboss-client</artifactId>
<version>4.0.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
<properties>
<mule.version>2.2.1</mule.version>
</properties>
</project>
2. Configuring the mule-config.xml. In this example we are using the default queue testQueue provided by JBoss to test the JMS Functionality.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"
xmlns:retry="http://www.mulesource.com/schema/mule/retry/2.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jbossts="http://www.mulesource.org/schema/mule/jbossts/2.2"
xmlns:jms="http://www.mulesource.org/schema/mule/jms/2.2"
xmlns:http="http://www.mulesource.org/schema/mule/http/2.2"
xmlns:stdio="http://www.mulesource.org/schema/mule/stdio/2.2"
xmlns:vm="http://www.mulesource.org/schema/mule/vm/2.2"
xsi:schemaLocation="
http://www.mulesource.org/schema/mule/file/2.2 http://www.mulesource.org/schema/mule/file/2.2/mule-file.xsd
http://www.mulesource.org/schema/mule/jbossts/2.2 http://www.mulesource.org/schema/mule/jbossts/2.2/mule-jbossts.xsd
http://www.mulesource.org/schema/mule/jms/2.2 http://www.mulesource.org/schema/mule/jms/2.2/mule-jms.xsd
http://www.mulesource.org/schema/mule/management/2.2 http://www.mulesource.org/schema/mule/management/2.2/mule-management.xsd
http://www.mulesource.org/schema/mule/cxf/2.2 http://www.mulesource.org/schema/mule/cxf/2.2/mule-cxf.xsd
http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd
http://www.mulesource.com/schema/mule/retry/2.2 http://www.mulesource.com/schema/mule/retry/2.2/mule-retry-ee.xsd
http://www.mulesource.org/schema/mule/stdio/2.2 http://www.mulesource.org/schema/mule/stdio/2.2/mule-stdio.xsd
http://www.mulesource.org/schema/mule/vm/2.2 http://www.mulesource.org/schema/mule/vm/2.2/mule-vm.xsd
http://www.mulesource.org/schema/mule/jetty/2.2 http://www.mulesource.org/schema/mule/jetty/2.2/mule-jetty.xsd
http://www.mulesource.org/schema/mule/http/2.2 http://www.mulesource.org/schema/mule/http/2.2/mule-http.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.mulesource.org/schema/mule/xml/2.2 http://www.mulesource.org/schema/mule/xml/2.2/mule-xml.xsd">
<jbossts:transaction-manager/>
<configuration>
<default-dispatcher-threading-profile maxThreadsActive="50" maxThreadsIdle="25"
threadTTL="60000"/>
<default-receiver-threading-profile maxThreadsActive="50" maxThreadsIdle="25"
threadTTL="60000"/>
<default-service-threading-profile maxThreadsActive="50" maxThreadsIdle="25"
threadTTL="60000"/>
</configuration>
<jms:connector name="jms-connector" jndiInitialFactory="org.jnp.interfaces.NamingContextFactory"
jndiProviderUrl="jnp://127.0.0.1:1099"
connectionFactoryJndiName="java:/QueueConnectionFactory" jndiDestinations="true"
forceJndiDestinations="true" createMultipleTransactedReceivers="true"
numberOfConcurrentTransactedReceivers="10" disableTemporaryReplyToDestinations="true">
<!--retry:forever-policy frequency="2000"/-->
</jms:connector>
<stdio:connector name="stdioConnector" promptMessage="Please enter message: " outputMessage="Received message: " messageDelayTime="3000"/>
<jms:object-to-jmsmessage-transformer name="ObjectToJMSMessageTransformer"/>
<jms:jmsmessage-to-object-transformer name="JMSMessageToObjectTransformer"/>
<model>
<service name="stdioToQueue">
<inbound>
<stdio:inbound-endpoint system="IN" synchronous="true"/>
</inbound>
<outbound>
<pass-through-router>
<jms:outbound-endpoint queue="queue/testQueue" synchronous="true"/>
</pass-through-router>
</outbound>
</service>
<service name="queueToStdio">
<inbound>
<jms:inbound-endpoint queue="queue/testQueue" synchronous="true"/>
</inbound>
<outbound>
<pass-through-router>
<stdio:outbound-endpoint system="OUT" synchronous="true"/>
</pass-through-router>
</outbound>
</service>
</model>
</mule>
3. Start the JBoss Server. This would bind the testQueue to JNDI.
4. Starting Mule Server. The Mule Server should get started successfully without any errors.
INFO 2011-07-26 23:49:32,035 [main] org.mule.MuleServer: Mule Server initializing...
INFO 2011-07-26 23:49:32,387 [main] org.mule.config.spring.MuleApplicationContext: Refreshing org.mule.config.spring.MuleApplicationContext@b753f8: display name [org.mule.config.spring.MuleApplicationContext@b753f8]; startup date [Tue Jul 26 23:49:32 CDT 2011]; root of context hierarchy
INFO 2011-07-26 23:49:33,285 [main] org.mule.config.spring.MuleApplicationContext: Bean factory for application context [org.mule.config.spring.MuleApplicationContext@b753f8]: org.springframework.beans.factory.support.DefaultListableBeanFactory@1b6101e
WARN 2011-07-26 23:49:33,704 [main] org.mule.registry.TransientRegistry: TransientRegistry already contains an object named '_ObjectToString'. The previous object will be overwritten.
WARN 2011-07-26 23:49:33,708 [main] org.mule.registry.TransientRegistry: TransientRegistry already contains an object named '_ObjectToByteArray'. The previous object will be overwritten.
WARN 2011-07-26 23:49:33,708 [main] org.mule.registry.TransientRegistry: TransientRegistry already contains an object named '_ObjectToOutputHandler'. The previous object will be overwritten.
WARN 2011-07-26 23:49:33,708 [main] org.mule.registry.TransientRegistry: TransientRegistry already contains an object named '_ObjectToInputStream'. The previous object will be overwritten.
WARN 2011-07-26 23:49:33,713 [main] org.mule.registry.TransientRegistry: TransientRegistry already contains an object named '_XmlToOutputHandler'. The previous object will be overwritten.
WARN 2011-07-26 23:49:33,715 [main] org.mule.registry.TransientRegistry: TransientRegistry already contains an object named '_DomDocumentToString'. The previous object will be overwritten.
WARN 2011-07-26 23:49:33,718 [main] org.mule.registry.TransientRegistry: TransientRegistry already contains an object named '_XmlToDocumentResult'. The previous object will be overwritten.
WARN 2011-07-26 23:49:33,720 [main] org.mule.registry.TransientRegistry: TransientRegistry already contains an object named 'XmlToDom4jDocument'. The previous object will be overwritten.
WARN 2011-07-26 23:49:33,723 [main] org.mule.registry.TransientRegistry: TransientRegistry already contains an object named 'XmlToW3CDocument'. The previous object will be overwritten.
WARN 2011-07-26 23:49:33,731 [main] org.mule.registry.TransientRegistry: TransientRegistry already contains an object named 'transformer.7'. The previous object will be overwritten.
WARN 2011-07-26 23:49:33,732 [main] org.mule.registry.TransientRegistry: TransientRegistry already contains an object named '_JMSMessageToByteArray'. The previous object will be overwritten.
WARN 2011-07-26 23:49:33,732 [main] org.mule.registry.TransientRegistry: TransientRegistry already contains an object named '_JMSMessageToString'. The previous object will be overwritten.
WARN 2011-07-26 23:49:33,732 [main] org.mule.registry.TransientRegistry: TransientRegistry already contains an object named '_JMSMessageToHashtable'. The previous object will be overwritten.
WARN 2011-07-26 23:49:33,733 [main] org.mule.registry.TransientRegistry: TransientRegistry already contains an object named '_JMSMessageToVector'. The previous object will be overwritten.
WARN 2011-07-26 23:49:33,733 [main] org.mule.registry.TransientRegistry: TransientRegistry already contains an object named '_JMSMessageToObject'. The previous object will be overwritten.
WARN 2011-07-26 23:49:33,734 [main] org.mule.registry.TransientRegistry: TransientRegistry already contains an object named '_ObjectToMessage'. The previous object will be overwritten.
INFO 2011-07-26 23:49:33,892 [main] org.mule.transport.jms.JmsConnector: Initialising: JmsConnector{this=1552b76, started=false, initialised=false, name='jms-connector', disposed=false, numberOfConcurrentTransactedReceivers=10, createMultipleTransactedReceivers=true, connected=false, supportedProtocols=[jms], serviceOverrides=null}
INFO 2011-07-26 23:49:34,129 [main] org.mule.DefaultExceptionStrategy: Initialising exception listener: org.mule.DefaultExceptionStrategy@8f9a32
INFO 2011-07-26 23:49:34,140 [main] org.mule.transport.stdio.PromptStdioConnector: Initialising: PromptStdioConnector{this=e99ce5, started=false, initialised=false, name='stdioConnector', disposed=false, numberOfConcurrentTransactedReceivers=4, createMultipleTransactedReceivers=true, connected=false, supportedProtocols=[stdio], serviceOverrides=null}
INFO 2011-07-26 23:49:34,150 [main] org.mule.DefaultExceptionStrategy: Initialising exception listener: org.mule.DefaultExceptionStrategy@15d252d
INFO 2011-07-26 23:49:34,237 [main] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default outbound transformer: org.mule.transport.jms.transformers.ObjectToJMSMessage
INFO 2011-07-26 23:49:34,241 [main] org.mule.component.simple.PassThroughComponent: Initialising: org.mule.component.simple.PassThroughComponent component for: SedaService{stdioToQueue}
INFO 2011-07-26 23:49:34,249 [main] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default inbound transformer: org.mule.transport.jms.transformers.JMSMessageToObject
INFO 2011-07-26 23:49:34,250 [main] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default response transformer: org.mule.transport.jms.transformers.ObjectToJMSMessage
WARN 2011-07-26 23:49:34,250 [main] org.mule.registry.TransientRegistry: TransientRegistry already contains an object named 'ObjectToMessage'. The previous object will be overwritten.
INFO 2011-07-26 23:49:34,253 [main] org.mule.component.simple.PassThroughComponent: Initialising: org.mule.component.simple.PassThroughComponent component for: SedaService{queueToStdio}
INFO 2011-07-26 23:49:34,254 [main] org.mule.config.builders.AutoConfigurationBuilder: Configured Mule using "org.mule.config.spring.SpringXmlConfigurationBuilder" with configuration resource(s): "[ConfigResource{resourceName='/C:/Vijay/Office/ganymedeWorkspace/MuleWork/MuleTutorial/src/main/resources/mule-config.xml'}]"
INFO 2011-07-26 23:49:34,254 [main] org.mule.config.builders.AutoConfigurationBuilder: Configured Mule using "org.mule.config.builders.AutoConfigurationBuilder" with configuration resource(s): "[ConfigResource{resourceName='/C:/Vijay/Office/ganymedeWorkspace/MuleWork/MuleTutorial/src/main/resources/mule-config.xml'}]"
INFO 2011-07-26 23:49:34,254 [main] org.mule.MuleServer: Mule Server starting...
INFO 2011-07-26 23:49:34,367 [main] org.mule.transport.jms.JmsConnector: Connected: JmsConnector{this=1552b76, started=false, initialised=true, name='jms-connector', disposed=false, numberOfConcurrentTransactedReceivers=10, createMultipleTransactedReceivers=true, connected=true, supportedProtocols=[jms], serviceOverrides=null}
INFO 2011-07-26 23:49:34,367 [main] org.mule.transport.jms.JmsConnector: Starting: JmsConnector{this=1552b76, started=false, initialised=true, name='jms-connector', disposed=false, numberOfConcurrentTransactedReceivers=10, createMultipleTransactedReceivers=true, connected=true, supportedProtocols=[jms], serviceOverrides=null}
INFO 2011-07-26 23:49:34,372 [main] org.mule.transport.jms.JmsConnector: Started: JmsConnector{this=1552b76, started=true, initialised=true, name='jms-connector', disposed=false, numberOfConcurrentTransactedReceivers=10, createMultipleTransactedReceivers=true, connected=true, supportedProtocols=[jms], serviceOverrides=null}
INFO 2011-07-26 23:49:34,373 [main] org.mule.transport.stdio.PromptStdioConnector: Connected: PromptStdioConnector{this=e99ce5, started=false, initialised=true, name='stdioConnector', disposed=false, numberOfConcurrentTransactedReceivers=4, createMultipleTransactedReceivers=true, connected=true, supportedProtocols=[stdio], serviceOverrides=null}
INFO 2011-07-26 23:49:34,373 [main] org.mule.transport.stdio.PromptStdioConnector: Starting: PromptStdioConnector{this=e99ce5, started=false, initialised=true, name='stdioConnector', disposed=false, numberOfConcurrentTransactedReceivers=4, createMultipleTransactedReceivers=true, connected=true, supportedProtocols=[stdio], serviceOverrides=null}
INFO 2011-07-26 23:49:34,373 [main] org.mule.transport.stdio.PromptStdioConnector: Started: PromptStdioConnector{this=e99ce5, started=true, initialised=true, name='stdioConnector', disposed=false, numberOfConcurrentTransactedReceivers=4, createMultipleTransactedReceivers=true, connected=true, supportedProtocols=[stdio], serviceOverrides=null}
INFO 2011-07-26 23:49:34,374 [main] org.mule.component.simple.PassThroughComponent: Starting: org.mule.component.simple.PassThroughComponent component for: SedaService{stdioToQueue}
INFO 2011-07-26 23:49:34,374 [main] org.mule.transport.stdio.PromptStdioConnector: Registering listener: stdioToQueue on endpointUri: stdio://system.in
INFO 2011-07-26 23:49:34,392 [main] org.mule.transport.stdio.StdioMessageReceiver: Connected: stdio://system.in
INFO 2011-07-26 23:49:34,397 [main] org.mule.model.seda.SedaService: Service stdioToQueue has been started successfully
INFO 2011-07-26 23:49:34,398 [main] org.mule.component.simple.PassThroughComponent: Starting: org.mule.component.simple.PassThroughComponent component for: SedaService{queueToStdio}
INFO 2011-07-26 23:49:34,398 [main] org.mule.transport.jms.JmsConnector: Registering listener: queueToStdio on endpointUri: jms://queue/testQueue
INFO 2011-07-26 23:49:34,448 [main] org.mule.transport.jms.MultiConsumerJmsMessageReceiver: Connected: jms://queue/testQueue
INFO 2011-07-26 23:49:34,451 [main] org.mule.model.seda.SedaService: Service queueToStdio has been started successfully
INFO 2011-07-26 23:49:34,451 [main] org.mule.util.queue.TransactionalQueueManager: Starting ResourceManager
INFO 2011-07-26 23:49:34,453 [main] org.mule.util.queue.TransactionalQueueManager: Started ResourceManager
INFO 2011-07-26 23:49:34,492 [main] org.mule.DefaultMuleContext:
**********************************************************************
* Mule ESB and Integration Platform *
* Version: 2.2.1 Build: 14422 *
* MuleSource, Inc. *
* For more information go to http://mule.mulesource.org *
* *
* Server started: 26/7/11 11:49 PM *
* Server ID: d196b253-b80b-11e0-a167-db747a402dbb *
* JDK: 1.6.0_21 (mixed mode, sharing) *
* OS encoding: UTF-8, Mule encoding: UTF-8 *
* OS: Windows Vista - Service Pack 2 (6.0, x86) *
* Host: vijay-Laptop (192.168.1.65) *
* *
* Agents Running: None *
**********************************************************************
5. Testing the application
Please enter message: this is a test message
INFO 2011-07-26 23:50:12,104 [stdioConnector.receiver.1] org.mule.transport.jms.JmsMessageDispatcher: Connected: endpoint.outbound.jms://queue/testQueue
INFO 2011-07-26 23:50:12,147 [MessageListenerThread - testQueue] org.mule.transport.stdio.StdioMessageDispatcher: Connected: endpoint.outbound.stdio://system.out
Received message: this is a test message