Fuse ESB JMS endpoints typically do not store any state information. You can, however, configure them to store a copy of the current JMS message being sent. The message can be stored either in memory or in a JDBC configured database.
Having the endpoint store a copy of the current JMS message can aid in recovery from failures. For example, if your application is deployed in a cluster of Fuse ESB containers you can configure your endpoints to fail over if one of the containers crashes. If your endpoints are configured to store state in a JDBC database, they can then resend any request that was in process.
You configure an endpoint to save a copy of the current message by setting its stateless
attribute to false
.
By default, JMS endpoints uses a memory based message store. The memory based message store is a simple hash map that is stored in active memory. It cannot persist in the event of a failure, does not support transactions, or access by multiple members of a cluster.
If you need to use a more robust message store, you can configure a provider endpoint to use a JDBC accessible database as a message store. A JDBC message store can be shared among a cluster of endpoints, can be persisted in the event of a failure, and, depending on the database, be enlisted in transactions.
To configure an endpoint to use a JDBC accessible datastore, you configure its
storeFactory
attribute to reference a bean configuring an instance of the
org.apache.servicemix.store.jdbc.JdbcStoreFactory
class.
Table 5.1 list the properties you can set for the JDBC store factory.
Table 5.1. Properties Used to Configure a JDBC Store Factory
Name | Description |
---|---|
clustered | Specifies if a datastore can be accessed by the members of an endpoint cluster. |
transactional | Specifies if the datastore can be enlisted in transactions. |
dataSource | Specifies the configuration for the data source to be used when creating the store. |
adapter | Specifies the configuration for the JDBC adapter used to connect to the data source. |
Note | |
---|---|
The values for dataSource and adapter will depend on the database you are using and the JDBC adapter you are using. |
The fragment in Example 5.1 shows the configuration needed for a stateful JMS provider endpoint using MySQL as a JDBC accessible datastore.
Example 5.1. Configuring a Statefull JMS Provider Endpoint
<jms:provider service="tns:widgetServer" endpoint="widgetPort" storeFactory="#storeFactory"> stateless="false" /> <bean id="storeFactory" class="org.apache.servicemix.store.jdbc.JdbcStoreFactory"> <property name="clustered" value="true"/> <property name="dataSource"> <ref local="mysql-ds"/> </property> </bean> <bean id="mysql-ds" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="com.mysql.jdbc.Driver"/> <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activemq?relaxAutoCommit=true"/> <property name="user" value="activemq"/> <property name="password" value="activemq"/> <property name="minPoolSize" value="5"/> <property name="maxPoolSize" value="10"/> <property name="acquireIncrement" value="3"/> <property name="autoCommitOnClose" value="false"/> </bean>
The fragment in Example 5.1 does the following:
Configures the endpoint's store factory by providing a reference to the bean configuring the factory. | |
Configures the endpoint to store a copy of the current message in the datastore. | |
Configures the JDBC factory store to create a datastore that can be accessed by a cluster of endpoints. | |
Configures the MySQL JDBC driver. |