小编Siz*_*ons的帖子

使用Bitronix Transcation Manager时,将Hibernate after_transaction设置为JTA连接释放模式是否安全?

根据Hibernate文档,在JTA环境中,默认的连接释放模式是after_statement,这意味着在每个语句之后释放hibernate逻辑连接.

释放逻辑连接后,将调用Connection close()方法,并从事务管理器中取消列出当前资源.

根据RedHat 交易开发者指南:

"delistResource方法用于将指定资源与目标对象中的事务上下文分离.应用程序服务器使用两个参数调用该方法:

An XAResources object, which represents the resource.
A flag to indicate whether the operation is due to the transaction being suspended (TMSUSPEND), a portion of the work has failed (TMFAIL), or a normal resource release by the application (TMSUCCESS)."
Run Code Online (Sandbox Code Playgroud)

由于Bitronix使用TMSUCCESS:

 currentTransaction.delistResource(xaResourceHolderState.getXAResource(), XAResource.TMSUCCESS);
Run Code Online (Sandbox Code Playgroud)

这意味着连接与当前事务分支取消关联,有时您可能最终为同一资源适配器争用2个不同的连接.

我认为保持连接的次数与事务一样多是一个更好的选择,因为我们通常每个事务执行多个语句.所以after_transaction释放模式听起来更有吸引力.

使用Bitronix,after_transaction释放模式更合适吗?有没有人在生产环境中体验过它?

hibernate transactions xa distributed-transactions bitronix

5
推荐指数
1
解决办法
2645
查看次数

为什么我不能安装我的Windows服务 - 指定的服务已经存在

我希望我现在可以在我的电脑上放一枚手榴弹.我很沮丧,因为我不明白为什么我的应用程序不会使用installUtil安装.

我现在只看了这个链接: Windows服务安装结束回滚,不幸的是那里的那些建议对我的情况没有帮助,在考虑到好人们发布的所有答案之后产生了以下错误.那个链接和其他人.

我已经在网上寻找任务并行处理模式的最佳实践,但到目前为止没有任何帮助.我尝试安装时遇到的最新错误如下:

.exe程序集的进度.该文件位于E:\ xxx\MyService\Service_V2.InstallLog.安装程序集'E:\ xxx\MyService\Service_V2.exe'.受影响的参数为:
logtoconsole = logfile = E:\ xxx\MyService\Service_V2.InstallLog
assemblypath = E:\ xxx\MyService\Service_V2.exe安装服务Service V2 ...已成功安装Service Service V2.在日志应用程序中创建EventLog源服务V2 ...安装服务服务V2 ...在日志应用程序中创建EventLog源服务V2 ...

安装阶段发生异常.System.ComponentModel.Win32Exception:指定的服务已存在

安装的回滚阶段正在开始.请参阅日志文件的内容以获取E:\ xxx\MyService\Service_V2 .exe程序集的进度.该文件位于E:\ xxx\MyService\Service_V2.InstallLog.回滚组件'E:\ xxx\MyService\Service_V2.exe'.受影响的参数为:
logtoconsole = logfile = E:\ xxx\MyService\Service_V2.InstallLog
assemblypath = E:\ xxx\MyService\Service_V2.exe将事件日志还原到源Service V2的先前状态.将事件日志还原到源Service V2的先前状态.正在从系统中删除Service Service V2 ...已成功从系统中删除Service Service V2.

回滚阶段成功完成.

事务处理安装已完成.安装失败,并且已执行回滚.

事件日志中也没有写入任何内容.

这是我的OnStart()方法:

protected override void OnStart(string[] args)
        {
            var tokenSource = new CancellationTokenSource();
            var token = tokenSource.Token;

            ErrorLogFileName = "Service_V2Errors" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
            Service_V2LogFile = "Service_V2Log" + DateTime.Now.ToString("yyyy-MM-dd") + …
Run Code Online (Sandbox Code Playgroud)

c# windows-services task-parallel-library

4
推荐指数
1
解决办法
5482
查看次数