8.3. pax-transx プロジェクト
pax-transx プロジェクトは、OSGi での JTA/JTS トランザクション管理、および JDBC および JMS のリソースプーリングのサポートを提供します。pax-jdbc と pax-jms の間の差異をなくします。
-
pax-jdbcは、javax.sql.(XA)ConnectionFactoryサービスの設定オプションと検出を追加し、JDBC プーリング実装の一部が提供されます。 -
pax-jmsは、javax.jms.(XA)ConnectionFactoryサービスと同じことを行い、一部の JMS プーリング実装を提供します。 -
pax-transxはjavax.transaction.TransactionManager実装の設定オプションおよび検出を追加し、(最終的に) JCA ベースの JDBC/JMS 接続管理をプーリングおよびトランザクションサポートとともに提供します。
JDBC 接続プール と JMS 接続プール のセクションは引き続き有効です。JCA ベースのプールを使用するために必要な変更は、JDBC データソースと JMS 接続ファクトリーの登録時に pool=transx プロパティーを使用することだけです。
-
pax-jdbc-pool-transxはpax-transx-jdbcのorg.ops4j.pax.transx.jdbc.ManagedDataSourceBuilderを使用します。 -
pax-jms-pool-transxはpax-transx-jmsのorg.ops4j.pax.transx.jms.ManagedConnectionFactoryBuilderを使用します。
プールされたデータソース/接続ファクトリーは ビルダースタイル (Java™ Bean プロパティーなし) で作成されますが、JDBC ではこれらのプロパティーがサポートされます。
-
name -
userName -
password -
commitBeforeAutocommit -
preparedStatementCacheSize -
transactionIsolationLevel -
minIdle -
maxPoolSize -
aliveBypassWindow -
houseKeepingPeriod -
connectionTimeout -
idleTimeout -
maxLifetime
これらのプロパティーは JMS でサポートされます。
-
name -
userName -
password -
clientID -
minIdle -
maxPoolSize -
aliveBypassWindow -
houseKeepingPeriod -
connectionTimeout -
idleTimeout -
maxLifetime
XA リカバリーが機能するには、userName と password プロパティーが必要です (Fuse 6.x の aries.xa.username プロパティーおよび aries.xa.password プロパティーと同様)。
Blueprint でのこの JDBC 設定 (pool=transx を考慮) は次のとおりです。
<!--
Database-specific, non-pooling, non-enlisting javax.sql.XADataSource
-->
<bean id="postgresql" class="org.postgresql.xa.PGXADataSource">
<property name="url" value="jdbc:postgresql://localhost:5432/reportdb" />
<property name="user" value="fuse" />
<property name="password" value="fuse" />
<property name="currentSchema" value="report" />
<property name="connectTimeout" value="5" />
</bean>
<!--
Expose database-specific data source with service properties
No need to expose pooling, enlisting, non database-specific javax.sql.DataSource - it'll be registered
automatically by pax-jdbc-config with the same properties as this <service>, but with higher service.ranking
-->
<service id="pool" ref="postgresql" interface="javax.sql.XADataSource">
<service-properties>
<!-- "pool" key is needed for pax-jdbc-config to wrap database-specific data source inside connection pool -->
<entry key="pool" value="transx" />
<!-- <service>/@id attribute doesn't propagate, but name of the datasource is required using one of: -->
<entry key="osgi.jndi.service.name" value="jdbc/postgresql" />
<!-- or: -->
<!--<entry key="dataSourceName" value="jdbc/postgresql" />-->
<!-- Other properties, that normally are needed by e.g., pax-jdbc-pool-transx -->
<entry key="pool.maxPoolSize" value="13" />
<entry key="pool.userName" value="fuse" />
<entry key="pool.password" value="fuse" />
</service-properties>
</service>
Blueprint でのこの JMS 設定 (pool=transx を考慮) は次のとおりです。
<!--
Broker-specific, non-pooling, non-enlisting javax.jms.XAConnectionFactory
-->
<bean id="artemis" class="org.apache.activemq.artemis.jms.client.ActiveMQXAConnectionFactory">
<argument index="0" value="tcp://localhost:61616" />
<!-- credentials needed for JCA-based XA-recovery -->
<argument index="1" value="admin" />
<argument index="2" value="admin" />
<property name="callTimeout" value="2000" />
<property name="initialConnectAttempts" value="3" />
</bean>
<!--
Expose broker-specific connection factory with service properties
No need to expose pooling, enlisting, non broker-specific javax.jms.XAConnectionFactory - it'll be registered
automatically by pax-jms-config with the same properties as this <service>, but with higher service.ranking
-->
<service id="pool" ref="artemis" interface="javax.jms.XAConnectionFactory">
<service-properties>
<!-- "pool" key is needed for pax-jms-config to wrap broker-specific connection factory inside connection pool -->
<entry key="pool" value="transx" />
<!-- <service>/@id attribute doesn't propagate, but name of the connection factory is required using one of: -->
<entry key="osgi.jndi.service.name" value="jms/artemis" />
<!-- or: -->
<!--<entry key="name" value="jms/artemis" />-->
<!-- Other properties, that normally are needed e.g., pax-jms-pool-transx -->
<entry key="pool.maxPoolSize" value="13" />
<entry key="pool.userName" value="admin" />
<entry key="pool.password" value="admin" />
</service-properties>
</service>
JCA ベースのリソース管理を活用する JDBC データソースと JMS 接続ファクトリーが登録されます。transx ベースのプールは XA リカバリーに関して pax-transx-tm-narayana と適切に統合されます。
必要な機能は以下のとおりです。
-
pax-jdbc-pool-tranx -
pax-jms-pool-tranx -
pax-transx-jdbc -
pax-transx-jms -
pax-jms-artemis(A-MQ 7 を使用する場合)