Configuring Fiorano MQ

The following information was tested with the default installation for FioranoMQ version: 2007 SP2 Build # 4383

Startup FioranoMQ in XA Mode

You need to start the Fiorano server in XA mode for transactions. Type this on the command line:

fmq.sh -profile FioranoMQ_XA

Example: Adapting the MessageDrivenBank Sample Application

The rest of this page shows how to adapt the supplied JMS-Spring sample (in the download) for FioranoMQ.

JNDI Properties

The FioranoMQ JMS objects are available in JNDI. You will need the following jndi.properties file in your classpath:

java.naming.factory.initial=fiorano.jms.runtime.naming.FioranoInitialContextFactory
java.naming.provider.url=http://localhost:1856
java.naming.security.principal=anonymous
java.naming.security.credentials=anonymous

Sample Spring XML Config

The following is an adapted sample XML config file for Spring, based on the MessageDrivenBank spring/jms sample in the TransactionsEssentials:

<beans>

<!-- For non-xa -->
<bean id="datasource" 
        class="com.atomikos.jdbc.nonxa.NonXADataSourceBean">

        <property name="user"><value>sa</value></property>
        <property name="url"><value>jdbc:HypersonicSQL:SpringNonXADB</value></property>
        <property name="driverClassName"><value>org.hsql.jdbcDriver</value></property>
        <property name="poolSize"><value>1</value></property>
        <property name="connectionTimeout"><value>60</value></property>
        

</bean>
<!-- NOTE: for XA datasources: don't forget to call init and close ! -->

<bean id="xaFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
  <property name="jndiName"><value>primaryXAQCF</value></property>
</bean>

<bean id="queue" class="org.springframework.jndi.JndiObjectFactoryBean">
  <property name="jndiName"><value>primaryRDBMSQueue</value></property>
</bean>

<bean id="bank" class="jdbc.Bank">
        <property name="dataSource"><ref bean="datasource"/></property>
</bean>

<bean id="messageDrivenBank" class="jms.MessageDrivenBank">
        <property name="bank"><ref bean="bank"/></property>
</bean>

<!-- Configure the JMS connector; call init to register for recovery! -->
<bean id="queueConnectionFactoryBean"
        class="com.atomikos.jms.QueueConnectionFactoryBean" init-method="init">
        
        <property name="resourceName"><value>QUEUE_BROKER</value></property>
        <property name="xaQueueConnectionFactory"><ref bean="xaFactory" /></property>   
</bean>

<!-- Configure the session pool for JMS. This will also manage the transactions
for incoming messages. -->
<bean id="queueReceiverSessionPool" 
        class="com.atomikos.jms.QueueReceiverSessionPool"
        init-method="start">
        <property name="queueConnectionFactoryBean">
                <ref bean="queueConnectionFactoryBean"/>
        </property>
        <property name="transactionTimeout"><value>120</value></property>
        <property name="poolSize"><value>1</value></property>
        <property name="queue"><ref bean="queue"/></property>
        <property name="messageListener"><ref bean="messageDrivenBank"/></property>
                
</bean>
</beans>

The MessageDrivenBank

The bank java code does not have to change - all dependencies are concentrated in the spring config file above.

Add Required Fiorano Jars

You should add the Fiorano jars to your classpath - see the Fiorano documentation on what jars you need.

Sending Messages to the Bank

To send a message to the bank, just make sure to send to the same queue, i.e. primaryRDBMSQueue in this example.

Downloadable Sample Code

You can download the entire sample code as a zip file here: fiorano-spring.zip

-- GuyPardon - 24 Sep 2007

Go
  File Size Date By Actions
zip fiorano-spring.zip
!MessageDrivenBank with FioranoMQ
7.7 K 24 Sep 2007 - 15:52 GuyPardon props, move
r2 - 25 Feb 2008 - 15:31:46 - MichaelDaum
This site is powered by the TWiki collaboration platformCopyright © contributing authors and Atomikos. All material on this collaboration platform is the shared property of the contributing authors and Atomikos.
Syndicate this site RSSATOM