此内容没有您所选择的语言版本。

Chapter 5. Making Endpoints Stateful


Abstract

You can configure JMS endpoints to store a copy of the current message exchange in a persistent datastore. This helps in cases where you need to recover from failures.
Important
The Java Business Integration components of Red Hat JBoss Fuse are considered deprecated. You should consider migrating any JBI applications to OSGi.

Overview

Red Hat JBoss Fuse 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 JBoss Fuse 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.

Activating statefullness

You configure an endpoint to save a copy of the current message by setting its stateless attribute to false.

Configuring the datastore

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, “Properties Used to Configure a JDBC Store Factory” list the properties you can set for the JDBC store factory.
Expand
Table 5.1. Properties Used to Configure a JDBC Store Factory
NameDescription
clusteredSpecifies if a datastore can be accessed by the members of an endpoint cluster.
transactionalSpecifies if the datastore can be enlisted in transactions.
dataSourceSpecifies the configuration for the data source to be used when creating the store.
adapterSpecifies 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.

Example

The fragment in Example 5.1, “Configuring a Statefull JMS Provider Endpoint” 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"> 1
              stateless="false" /> 2

<bean id="storeFactory" 3
      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" 4
      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>
Copy to Clipboard Toggle word wrap
1
Configures the endpoint's store factory by providing a reference to the bean configuring the factory.
2
Configures the endpoint to store a copy of the current message in the datastore.
3
Configures the JDBC factory store to create a datastore that can be accessed by a cluster of endpoints.
4
Configures the MySQL JDBC driver.
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat