MDB onMessage 失败并关闭 JDBC 连接
MDB onMessage fails with closed JDBC connection
运行 JBoss eap 7.0 上的应用程序。我有一个 MDB,它还引用 XA 数据源 (oracle) 来保存数据。长时间不使用(几个小时)后,下一次写入数据库的 onMessage 调用出现以下错误
org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
Caused by: java.sql.SQLException: javax.resource.ResourceException:
IJ000457: Unchecked throwable in managedConnectionReconnected()
cl=org.jboss.jca.core.connectionmanager.listener.TxConnectionListener@178ff38
2[state=DESTROYED managed
connection=org.jboss.jca.adapters.jdbc.xa.XAManagedConnection@70289860 connection handles=0 lastReturned=1506796773697 lastValidated=1506796773525 lastCheckedOut=1506947349429 trackByTx=false
pool=org.jboss.jca.core.connectionmanager.pool.strategy.OnePool@5968abc8
mcp=SemaphoreConcurrentLinkedQueueManagedConnectionPool@83405c5[pool=HIF-
BannerPU]
xaResource=XAResourceWrapperImpl@2168086b[xaResource=org.jboss.jca.adapters.j
dbc.xa.XAManagedConnection@70289860 pad=false overrideRmValue=null
productName=Oracle productVersion=Oracle Database 12c Enterprise Edition
Release 12.2.0.1.0 - 64bit Production jndiName=java:/jdbc/HIF-BannerPU]
txSync=null
我应该设置 validate-on-match = true,还是有更好的方法来确保合并的连接有效且活跃?
更新:将配置更改为:
<validation>
<validate-on-match>true</validate-on-match>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter" />
</validation>
<xa-pool>
<is-same-rm-override>false</is-same-rm-override>
<no-tx-separate-pools />
</xa-pool>
仍然出现错误。
是的,连接池验证设置对所有数据源都是强制性的:
<validation>
<validate-on-match>true</validate-on-match> <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"></valid-connection-checker>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"></exception-sorter>
</validation>
还要验证 is-same-rm-override 和 no-tx-separate-pools 元素在每个 Oracle 特定涉及的 xa-datasource 中明确声明(https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html-single/configuration_guide/#example_oracle_xa_datasource)
<xa-pool> ...
<is-same-rm-override>false</is-same-rm-override>
<no-tx-separate-pools />
</xa-pool>
运行 JBoss eap 7.0 上的应用程序。我有一个 MDB,它还引用 XA 数据源 (oracle) 来保存数据。长时间不使用(几个小时)后,下一次写入数据库的 onMessage 调用出现以下错误
org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
Caused by: java.sql.SQLException: javax.resource.ResourceException:
IJ000457: Unchecked throwable in managedConnectionReconnected()
cl=org.jboss.jca.core.connectionmanager.listener.TxConnectionListener@178ff38
2[state=DESTROYED managed
connection=org.jboss.jca.adapters.jdbc.xa.XAManagedConnection@70289860 connection handles=0 lastReturned=1506796773697 lastValidated=1506796773525 lastCheckedOut=1506947349429 trackByTx=false
pool=org.jboss.jca.core.connectionmanager.pool.strategy.OnePool@5968abc8
mcp=SemaphoreConcurrentLinkedQueueManagedConnectionPool@83405c5[pool=HIF-
BannerPU]
xaResource=XAResourceWrapperImpl@2168086b[xaResource=org.jboss.jca.adapters.j
dbc.xa.XAManagedConnection@70289860 pad=false overrideRmValue=null
productName=Oracle productVersion=Oracle Database 12c Enterprise Edition
Release 12.2.0.1.0 - 64bit Production jndiName=java:/jdbc/HIF-BannerPU]
txSync=null
我应该设置 validate-on-match = true,还是有更好的方法来确保合并的连接有效且活跃?
更新:将配置更改为:
<validation>
<validate-on-match>true</validate-on-match>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter" />
</validation>
<xa-pool>
<is-same-rm-override>false</is-same-rm-override>
<no-tx-separate-pools />
</xa-pool>
仍然出现错误。
是的,连接池验证设置对所有数据源都是强制性的:
<validation>
<validate-on-match>true</validate-on-match> <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"></valid-connection-checker>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"></exception-sorter>
</validation>
还要验证 is-same-rm-override 和 no-tx-separate-pools 元素在每个 Oracle 特定涉及的 xa-datasource 中明确声明(https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html-single/configuration_guide/#example_oracle_xa_datasource)
<xa-pool> ...
<is-same-rm-override>false</is-same-rm-override>
<no-tx-separate-pools />
</xa-pool>