locked
MSMQ an NIbernate ITransaction abstraction RRS feed

  • Question

  • HI

    I have this domain model based on NHibernate where i built an abastraction for the transaction.
    Tipically we use it like this(IoC code ommited)

     ITransactionContextFactory _factory = new NHibernateTransactionFactory(_session);
     ITransactionContext _transaction = _factory.BeginTransaction();
     
     [...] Business code, etc
     
     
     _transaction.Commit() (or _transaction.Rollback());
     
     And the interfaces are like this:
      public interface ITransactionContextFactory
        {
            ITransactionContext BeginTransaction();
            ITransactionContext BeginTransaction(IsolationLevel isolationLevel);
        }
     
      public interface ITransactionContext
        {
            void Commit();
            void RollBack();
        }


    Now i need to use MSMQ transactional queus but i wanted to use the same interfaces, something like this

     ITransactionContextFactory _factory = new MSMQTransactionFactory(MSMQTransaction);
     ITransactionContext _transaction = _factory.BeginTransaction();
     
     [...] Business code, etc
     
     
     _transaction.Commit() (or _transaction.Rollback());
     
     My problem is this. This code does not work because i cant get the MSMQTransaction out of
     the ITransactionContext and i need it to pass it to the queu.
     Any sugestions on how i can abastract MSMQ transaction like any other DB transaction.
     I even thougt about build some kind of repository for MSMQ but i have the same problem.
     
     
     Thanks

    Tuesday, February 23, 2010 12:11 PM