Integration with Mule takes places via a JMS Connector. The description of a JMS Connector can be found in the Mule documentation.
To integrate SwiftMQ it is recommended to integrate it via JNDI, thus, the following attributes have to be specified:
| Attribute | Description | Recommended Value |
|---|---|---|
| jndiInitialFactory | InitialContext factory | com.swiftmq.jndi.InitialContextFactoryImpl |
| jndiProviderUrl | JNDI Provider URL | smqp://localhost:4001/timeout=10000 |
| jndiDestinations | JNDI lookup of queues/topics | true |
| forceJndiDestinations | Forces a JNDI exception if a destination was not found in JNDI | true |
| specification | Version of the JMS specification | 1.1 |
| connectionFactoryJndiName | Name of the JMS connection factory to use | ConnectionFactory |
Example:
<connector name="jmsConnector" className="org.mule.providers.jms.JmsConnector">
<properties>
<property name="connectionFactoryJndiName" value="ConnectionFactory"/>
<property name="jndiInitialFactory" value="com.swiftmq.jndi.InitialContextFactoryImpl"/>
<property name="jndiProviderUrl" value="smqp://localhost:4001/timeout=10000"/>
<property name="jndiDestinations" value="true"/>
<property name="forceJndiDestinations" value="true"/>
<property name="specification" value="1.1"/>
</properties>
</connector>
Copy swiftmq.jar into Mule's "lib/user" directory and start the SwiftMQ Router. Now you can use SwiftMQ from Mule.
The description of the LoanBroker ESB example can be found in the Mule documentation.
The only change necessary in both example configuration files loan-broker-esb-mule-config.xml and loan-broker-esb-mule-config-container.xml is the JMS connector. With a SwiftMQ Router running on the local host it is:
<connector name="jmsConnector" className="org.mule.providers.jms.JmsConnector">
<properties>
<property name="connectionFactoryJndiName" value="ConnectionFactory"/>
<property name="jndiInitialFactory" value="com.swiftmq.jndi.InitialContextFactoryImpl"/>
<property name="jndiProviderUrl" value="smqp://localhost:4001/timeout=10000"/>
<property name="jndiDestinations" value="true"/>
<property name="forceJndiDestinations" value="true"/>
<property name="specification" value="1.1"/>
</properties>
</connector>
The LoanBroker ESB example uses the following JMS queues (Mule syntax):
jms://esb.loan.quotes
jms://esb.credit.agency
jms://esb.lender.service
jms://esb.banks
SwiftMQ does not allow dots '.' in queue names. Instead we use underscores '_' in SwiftMQ's routerconfig.xml:
<swiftlet name="sys$queuemanager">
<queue-controllers>
<queue-controller name="01" persistence-mode="non_persistent" predicate="tmp$%"/>
<queue-controller name="02" predicate="sys$%"/>
<queue-controller name="03" predicate="swiftmq%"/>
<queue-controller name="04" predicate="rt$%"/>
<queue-controller name="05" predicate="unroutable"/>
<queue-controller name="06" predicate="%$%"/>
<queue-controller name="07" predicate="%"/>
</queue-controllers>
<queues>
<queue name="esb_banks"/>
<queue name="esb_credit_agency"/>
<queue name="esb_lender_service"/>
<queue name="esb_loan_quotes"/>
</queues>
</swiftlet>
To match with the LoanBroker ESB example's JMS queue names, we define JNDI aliases in SwiftMQ's routerconfig.xml
<swiftlet name="sys$jndi">
<aliases>
<alias name="esb.banks" map-to="esb_banks@router1"/>
<alias name="esb.credit.agency" map-to="esb_credit_agency@router1"/>
<alias name="esb.lender.service" map-to="esb_lender_service@router1"/>
<alias name="esb.loan.quotes" map-to="esb_loan_quotes@router1"/>
</aliases>
<jndi-replications/>
<remote-queues/>
</swiftlet>
That's it! The LoanBroker ESB example must be rebuild with Ant or Maven in order that the configuration changes take effect. Then start the SwiftMQ Router and the LoanBroker ESB example.