简体   繁体   English

Wildfly交易

[英]Wildfly Transactions

My Wildfly server is running a copy method which takes 30 minutes to finish. 我的Wildfly服务器正在运行一个复制方法,该过程需要30分钟才能完成。 For every copied item i got a log message. 对于每个复制的项目,我都会收到一条日志消息。 Ater 10 minutes the server is printing following message for around 20 seconds: 在10分钟时,服务器将打印以下消息约20秒:

javax.persistence.PersistenceException:org.hibernate.exception.GenericJDBCException: Could not open connection javax.persistence.PersistenceException:org.hibernate.exception.GenericJDBCException:无法打开连接

After this the server is continuing with the copy operation. 此后,服务器将继续进行复制操作。 However, when the server is finished all transactions are rolledback. 但是,服务器完成后,所有事务都会回滚。 So I tried to add this annotation for my copy method: 因此,我尝试为我的复制方法添加此批注:

@TransactionAttribute(REQUIRES_NEW)

Now the server is running the copy operation without any exception but at the end the log says: 现在服务器正在运行复制操作,没有任何异常,但是最后日志显示:

2016-06-30 14:41:06,262 WARN [com.arjuna.ats.jta] (Thread-1195 (HornetQ-client-global-threads-252748997)) ARJUNA016041: prepare on < formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffff7f000101:-76961d26:577503fd:1297, node_name=1, branch_uid=0:ffff7f000101:-76961d26:577503fd:1298, subordinatenodename=null, eis_name=unknown eis name > (DelegatingSession [session=ClientSessionImpl [name=c2eb2924-3eb6-11e6-8fd4-954338fa95f0, username=null, closed=false, factory = ClientSessionFactoryImpl [serverLocator=ServerLocatorImpl [initialConnectors=[TransportConfiguration(name=bdde9687-3eb6-11e6-8fd4-954338fa95f0, factory=org-hornetq-core-remoting-impl-invm-InVMConnectorFactory) ?server-id=0], discoveryGroupConfiguration=null], connectorConfig=TransportConfiguration(name=bdde9687-3eb6-11e6-8fd4-954338fa95f0, factory=org-hornetq-core-remoting-impl-invm-InVMConnectorFactory) ?server-id=0, backupConfig=null], metaData=(jms-session=,resource-adapter=inbound,)]@62eae143]) failed with except 2016-06-30 14:41:06,262警告[com.arjuna.ats.jta](线程1195(HornetQ-client-global-threads-252748997))ARJUNA016041:在<formatId = 131077,gtrid_length = 29,bqual_length上进行准备= 36,tx_uid = 0:ffff7f000101:-76961d26:577503fd:1297,node_name = 1,branch_uid = 0:ffff7f000101:-76961d26:577503fd:1298,subordinatenodename = null,eis_name =未知的eis名称>((委托会话[session = ClientSessionImpl [名称= c2eb2924-3eb6-11e6-8fd4-954338fa95f0,用户名=空,关闭= false,工厂= ClientSessionFactoryImpl [serverLocator = ServerLocatorImpl [initialConnectors = [TransportConfiguration(name = bdde9687-3eb6-11e6-8fd4-954338fa95f0,factory = org-hornetq -core-remoting-impl-invm-InVMConnectorFactory)吗?服务器ID = 0],discoveryGroupConfiguration = null],connectorConfig = TransportConfiguration(name = bdde9687-3eb6-11e6-8fd4-954338fa95f0,factory = org-hornetq-core-remoting- impl-invm-InVMConnectorFactory)?server-id = 0,backupConfig = null],metaData =(jms-session =,resource-adapter = inbound,)] @ 62eae143])失败,除了 ion XAException.XA_RBOTHER: javax.transaction.xa.XAException ion XAException.XA_RBOTHER:javax.transaction.xa.XAException

And again all transactions are rolledback. 并再次回滚所有事务。 The Wildfly Admin Console Statistics seems normal. Wildfly管理控制台统计信息似乎正常。 When I try to copy less items the operation is running successful without any problems. 当我尝试复制较少的项目时,该操作运行成功,没有任何问题。 I also tried to increase the transaction-default-timeout value but with the same result. 我也尝试增加transaction-default-timeout值,但结果相同。

Update: I have a MySQL Database and I want to copy one bean into the same table with some other values. 更新:我有一个MySQL数据库,我想将一个bean和其他一些值复制到同一张表中。 The code is around 1000 lines. 该代码大约有1000行。

The Hibernate exception is occurs at following part Hibernate异常发生在以下部分

try {
    Query query = em.createQuery("SELECT g FROM PCTree g WHERE.parentKey = :parentKey ORDER BY g.orderNumber");
    query.setParameter("parentKey", parentKey);
    List res = query.getResultList();
    return res;
} catch (Exception e) {
    throw new FinderException("find PCTree.findByParentKey: " + parentKey + " => " + e);
}

But I think there is some connection/transaction/etc. 但是我认为有一些连接/事务/等等。 pool overflowing. 池溢出。 However the Wildfly statistics about the connection and transaction seems normal. 但是,有关连接和事务的Wildfly统计信息似乎很正常。

Try to add "autoreconnect" to the JNDI datasource you've configured in WildFly. 尝试将“自动重新连接”添加到在WildFly中配置的JNDI数据源。 Don't forget to reload the server after doing so. 这样做后,请不要忘记重新加载服务器。

jdbc:mysql://localhost:3306/database?autoReconnect=true

you have a limited connection number in the datasource pool. 您在数据源池中的连接数有限。 With this annotation you will create a new transaction per method call. 使用此注释,您将为每个方法调用创建一个新的事务。 Check that your datasource is not configured as XA datasource if you don't need multiple resources like JMS and database in the same transaction. 如果在同一事务中不需要像JMS和数据库这样的多个资源,请检查您的数据源是否未配置为XA数据源。 If you really needs to use XA transactions maybe you need to reuse connections per transaction. 如果您确实需要使用XA事务,则可能需要重用每个事务的连接。 It is a common thing in several jboss's quickstarts to use a shared transaction manager between a JMS queue and a XA datasource. 在几个jboss的快速入门中,在JMS队列和XA数据源之间使用共享事务管理器是很常见的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM