Edit | Attach | New | Raw | Delete | History | Print | Tools

Configuring FioranoMQ

WARNING: This page still uses the older JMS connectors, and needs updating to the newer JMS drivers available in the current Atomikos releases (also see Using TransactionsEssentials with JMS).

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

Attach
zip version 1 uploaded by GuyPardon on 24 Sep 2007 - 11:52
!MessageDrivenBank with FioranoMQ
spacer
Copyright © 2014 Atomikos BVBA. Transaction Management for Extreme Transaction Processing and SOA Environments serving ISV, Commercial, OEM and Open Source Markets
Site map RSS ATOM