Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9078737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:41:59+00:00 2026-06-16T19:41:59+00:00

This is more of a conceptual question. I’m writing a transactional based server-client application

  • 0

This is more of a conceptual question.
I’m writing a transactional based server-client application with the use of ORM.. Basically it means every layer knows how to work with transaction blocks for example here is a web service layer implementation:

public HandleTransaction<TReturn>(Action<TReturn>)
{
    bool opendByMe = false;

    // Some static transaction manager
    var transactionMgr = GetTransactionManager();

    try
    {
       // If not opened before me
       if(!transactionMgr.IsActive)
       {
           transactionMgr.BeginTransaction();
           opendByMe = true;
       }    

       // Run the action
       var returnValue = action();

       // If we opened the transaction then we should close it
       if(opendByMe)
       {
           transactionMgr.Commit();
       }

       return returnValue;
    }

    catch
    {
       if(opendByMe)
       {
          if(transactionMgr.IsActive)
          {
              // Rollback only if i opened the transaction
              transactionMgr.Rollback();  
          }  
       }

       // Else, bubble exception
       throw;
    }
}

public void ServiceWork1()  
{  
    // Subscribe to person event
    PersonBL.PersonChanged += HandlePersonChanged(Person pers);

    HandleTransaction(() =>  
          {  
                // BL actions are made in a bulk.. If one of them fails the transaction  
                // should be rolled back  
                PersonBL.CreatePerson("Jeff");  
                PersonBL.CreatePerson("John");  
                PersonBL.CreatePerson("Peter");  
              };)  
    }   

public void HandlePersonChanged(Person pers)
{
    // Notify some one
}

This works great but now I want to add some event to my application
i.e PersonCreatedEvent.. The problem is integrating the event bubbling with the transactions.. In the example above lets say the PersonBL.CreatePerson() method fires a “PersonChanged” event to the service layer.. Then the service layer handles this event and fires an event to the client.. But I don’t want to fire these events before I know for sure that the transaction was committed. The BL layer doesn’t know my business transaction logic so it fires the event in the CreatePerson method..
Is there any design solution for stacking/handling the events i subscribed to only after I completed the transaction?

To simplify my question: I want to execute HandlePersonChanged in a bulk after commit only..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:42:00+00:00Added an answer on June 16, 2026 at 7:42 pm

    I’ve ended up building an Action Queue which stores all the events fired during the transaction from different components.
    Then, upon committing a transaction in the ORM (I have an OnCommit event) the queue fires all it’s stored events one by one.. Of course, if the OnRollback event is fired, the Action queue is cleared and restarted.
    This “Action queue” is in the Infrastructure layer which is known across all layers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is more a conceptual question. Here is my current predicament; I am writing
This is more like a conceptual question. When to use Model Binding (in ASP.NET
I have an interesting situation here this time. This more of a conceptual question,
This is more of a conceptual question, but it has actual ramifications. Going through
This is more of a conceptual question concerning the built in functionality of PHP
this is more of a conceptual question. Is it aceptable/good programming mixing do/while loops
This is more of a conceptual question than anything. I have a base class
This is more of a conceptual question. If it helps, lets say it falls
This is more of a conceptual question than an actual implementation and am hoping
EDIT : this question is very similar to this one but it's more conceptual

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.