zoukankan      html  css  js  c++  java
  • Dynamics AX 2012 R2 AIF自定义服务中的事务回滚Bug

    Reinhard在一个Customer Service里的一个Method中,发现一个Transcation RollBack Bug。先看该Method的代码:

    [SysEntryPointAttribute(true)]
    public void SomeMethod()
    {
        ttsbegin;
            createJournalTable;
            createJournalLine;
        ttsend;
        try
        {
            //throw error inside postJournalTable
            throw error('some error message');
        }
        catch
        {
            //Could not catch Exception::Error
        }
    }

        在这个Method中,有一个创建Journal的Transcation,在Transcation外面,有一个 Try Catch Block,用于捕获Exception。

    Reinhard发现如果Exception是Error类型的话,Reinhard的Try Catch Block是捕捉不到的。会导致Whole Method RollBack。也就是说,Journal不会被创建。

        如果Exception的类型是Error以外的类型,Reinhard的Try Catch Block可能捕捉得到。In this case,Journal 可以被创建。

    Reinhard查了很多资料,Some Guy 说,是因为Aif Framework Core Code中,有一个Big Transcation导致的。

        在Reinhard的例子里,Reinhard要在Try Catch Block中执行PostJournal操作。Reinhard不是很关心该操作的执行结果——成功,还是失败。但是该操作如果产生Error类型的Exception的话,会导致Whole Method RollBack,Journal也不会被创建。

        解决方案是,将可能导致Error的PostJournal的操作剥离出来,放到一个Batch中,定时执行。

  • 相关阅读:
    后端注册接口完善
    编写注册接口
    Git 多人开发及常见问题
    Git 常用命令
    GIT 的安装及配置SSH
    ORM查询方法(整理)
    HTTP的系列理解与整理
    Unity C# 反射
    C# 中的委托和事件
    Unity C# 运用 GetSaveFileName() 导出Excel文件
  • 原文地址:https://www.cnblogs.com/msdynax/p/aif-customer-service-transcation-rollback-bug.html
Copyright © 2011-2022 走看看