このコンテンツは選択した言語では利用できません。

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

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat