JBoss在连接超时时重新连接 [英] JBoss reconnecting on connection time out
问题描述
我希望在我的连接死亡时重新连接。
我得到的问题,我在这里解释 https://stackoverflow.com/questions/25504566/jta-transaction-in-other-thread-rolling-back
我没有'弄清楚为什么会发生这种情况,但我现在已经无法发生死锁,所以我会等一个星期看看它是否已修复。
I want to reconnect when my connection dies.
The problem I'm getting, I explained here https://stackoverflow.com/questions/25504566/jta-transaction-in-other-thread-rolling-back
I haven't worked out why it happens, but I've made it impossible now for deadlocks to occur, so I will wait for a week to see if it's fixed.
但是我以为我的设置应该在失败连接时重新连接。但相反,JTA问题导致了我的连接,而且它没有回来。大概是因为它是CMT,只有一个连接,它通过 @PersistenceContext
传递,所以相同的 EntityManager
是用于一切,所以要重新连接,它必须从 EntityManagerFactory
获得一个新的 EntityManager
,但它没有'我知道这样做。我不知道JBoss和JPA的内部结构。
But I thought my setup should reconnect on failing connection. But instead, the JTA issue kills my connection, and it doesn't come back. Presumably because it's CMT, there is one connection only, which is passed around via @PersistenceContext
, so the same EntityManager
is used for everything, so to reconnect, it would have to get a new EntityManager
from the EntityManagerFactory
, but it doesn't know to do that. I don't know the innards of JBoss and JPA.
这是我的设置:
<datasources>
<datasource jndi-name="java:/DS" pool-name="DS" enabled="true" use-java-context="true">
<connection-url>jdbc:sqlserver://srv.local:1433;databaseName=AS_DEV</connection-url>
<driver>sqlserver2008</driver>
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>50</max-pool-size>
<prefill>false</prefill>
<use-strict-min>false</use-strict-min>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
<security>
<user-name>user</user-name>
<password>12345</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLValidConnectionChecker"/>
</validation>
</datasource>
<drivers>
<driver name="sqlserver2008" module="com.microsoft">
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
</driver>
</drivers>
</datasources>
我还能做些什么来确保失败时恢复连接?
What else can I do, to ensure a revived connection on failure?
推荐答案
这解决了它:
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLValidConnectionChecker"/>
<validate-on-match>true</validate-on-match>
<background-validation>true</background-validation>
</validation>
这篇关于JBoss在连接超时时重新连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!