locked
Biztalk atomic scope variable sharing RRS feed

  • Question

  • HI experts,

    Is there any way to share variables in atomic scope to long running scope.

    My design is i have atomic scope in long running, when some exception happens, catch block is fired.

    Now i need to pass the values from atomic scope to log in catch block.

    Tuesday, November 25, 2014 11:33 AM

Answers

  • I understand that you have

    • Long-Running Scope with a catch block
    • Atomic scope inside the Long-Running Scope.
    • You have declared a variable in Long-Running Scope.
    • You have declared another variable in Atomic scope
    • In Atomic scope - you assigned some value to the variable declared in Atomic scope
    • In Atomic scope - You assigned the value of the variable declared in Atomic scope to the variable declared in parent Long-Running Scope.
    • In Atomic scope - then an error occurred.
    • Control moved to the catch block of the Long-Running Scope.
    • In Long-Running Scope – you’re try to access the variable which was declared in parent Long-Running Scope. But the value is null. You expect the value which you assigned inside the atomic scope to be there in the catch block.

    No. You will not have the value assigned in atomic scope in Long-running scope's catch block, if atomic scope has errored (or not completed). This is how atomic scope works. ACID property.  FYI -at the same time if within the atomic scope, you have done some changes outside the BizTalk like some changes to external db, and then the changes in external db persist even atomic scope has failed. For this purpose you need to use compensate.

    Just to make you understand, if just change the transaction type property of the Atomic scope to Long-running and let the failure happen within the code of the new long running scope (which you changed). You can access the value of the variable in the Parent Long-running scope's catch block.



    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.


    • Edited by M.R.Ashwin Prabhu Tuesday, November 25, 2014 4:22 PM
    • Marked as answer by sandydv85 Thursday, November 27, 2014 3:08 PM
    Tuesday, November 25, 2014 4:22 PM

All replies

  • For your case, you have to define the variable in long-running scope. You can access this variable in atomic scope (which is inside the long running scope).

    So if any value has been "assigned in atomic scope" (to an variable which is actually "defined in its parent long-running scope"), and it shall be accessed in long-running scope. If any failure occurs in atomic scope after some value has been assigned to a login-running scope’s variable, you can still access the value in your catch. Because scope of the variable is defined in long-running.


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.


    Tuesday, November 25, 2014 11:50 AM
  • HI Aswin,

    I am not getting the values in catch block.

    In ATOMIC scope am getting the value , then am passing that to LongRunning variable.

    I can confirm value is coming to that variable as i can see that in event log.

    When exception throws, value is coming as null in CATCH block expression shape.

    Tuesday, November 25, 2014 12:12 PM
  • No ,there is no way where you share child scope variable into parent scope variable .The best way is to define the variable in parent scope (in your case its long running scope )and use the variable into atomic scope.
    Tuesday, November 25, 2014 2:03 PM
  • In ATOMIC scope am getting the value...value is coming as null in CATCH block expression shape.

    There's something missing.  Atomic Scopes do not have 'CATCH' blocks, only Compensation blocks.  When Compensation is run, the owning Scope has already completed so any variables are back to uninitialized.

    Tuesday, November 25, 2014 2:30 PM
    Moderator
  • I understand that you have

    • Long-Running Scope with a catch block
    • Atomic scope inside the Long-Running Scope.
    • You have declared a variable in Long-Running Scope.
    • You have declared another variable in Atomic scope
    • In Atomic scope - you assigned some value to the variable declared in Atomic scope
    • In Atomic scope - You assigned the value of the variable declared in Atomic scope to the variable declared in parent Long-Running Scope.
    • In Atomic scope - then an error occurred.
    • Control moved to the catch block of the Long-Running Scope.
    • In Long-Running Scope – you’re try to access the variable which was declared in parent Long-Running Scope. But the value is null. You expect the value which you assigned inside the atomic scope to be there in the catch block.

    No. You will not have the value assigned in atomic scope in Long-running scope's catch block, if atomic scope has errored (or not completed). This is how atomic scope works. ACID property.  FYI -at the same time if within the atomic scope, you have done some changes outside the BizTalk like some changes to external db, and then the changes in external db persist even atomic scope has failed. For this purpose you need to use compensate.

    Just to make you understand, if just change the transaction type property of the Atomic scope to Long-running and let the failure happen within the code of the new long running scope (which you changed). You can access the value of the variable in the Parent Long-running scope's catch block.



    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.


    • Edited by M.R.Ashwin Prabhu Tuesday, November 25, 2014 4:22 PM
    • Marked as answer by sandydv85 Thursday, November 27, 2014 3:08 PM
    Tuesday, November 25, 2014 4:22 PM
  • Thanks for info

    Regards

    Enis,

    Sunday, November 30, 2014 3:13 PM