I *finally* figured out the root of the issue. I had set the NHibernate connection.release_mode to "on_close" because the NH docs say that mode is better to use with System.Transactions. Apparently those docs are outdated, because the "on_close" mode does NOT work with system.transactions, even in very simple test cases. As soon as I set the connection release mode to "auto" I stopped getting this exception, and I started seeing log messages about transaction enlistments and rolling back the DTC transaction. 3 days of exploration for a 2 second fix, but it's working!
Udi, with this change I actually didn't have to change my MessageModule. I saw what you did in NSB, but since I'm using rhino UnitOfWork instead of the raw NHibernate session I could not do something similar, but fortunately I didn't have to. -tyler burd On Tue, Aug 4, 2009 at 2:00 AM, Udi Dahan <[email protected]>wrote: > > I had a similar problem when moving to NH 2.1 - it required some > changes to the exception handling around transaction boundaries. > > Here's the story: > > NH 2.1 now automatically joins the distributed transaction managed by > the bus, and flushes/closes/disposes with the commit. > This results in exceptions at the message module level, or the > transport/transaction level that used to happen at the message handler > level. > > * Our message module is quite a bit simpler, only opening a session > and binding it to the current context. > > Hope that helps. > -- Udi Dahan > > On Aug 3, 8:08 pm, Tyler Burd <[email protected]> wrote: > > I think I've isolated the problem to NHibernate. I posted about the > issue > > on the nhusers list. Hopefully that will get me somewhere. Is anyone > else > > using the NH trunk with RSB? What do your MessageModules look like? > > > > On Mon, Aug 3, 2009 at 8:46 AM, tyler.burd <[email protected]> wrote: > > > Hi again. I'm trying to use NHibernate, ActiveRecord, and Rhino's > > > UnitOfWork together with RSB (everything from the trunks). I am using > > > a MessageModule to initiate a UnitOfWork (listed at the end of the > > > message). I have a simple message handler that simply loads an entity > > > via IRepository, changes a few properties, and then throws an > > > exception to force a rollback. Extremely simple test case, but I keep > > > getting this exception when a message is handled: > > > Completed transaction was disposed, assuming transaction rollback > > > System.ObjectDisposedException: Cannot access a disposed object. > > > Object name: 'Transaction'. > > > at System.Transactions.Transaction.get_TransactionInformation() > > > at > > > > > > NHibernate.Transaction.AdoNetWithDistrubtedTransactionFactory.<>c__DisplayClass1.<EnlistInDistributedTransactionIfNeeded>b__0 > > > (Object sender, TransactionEventArgs e) in d:\oss\2009-07-27\nhibernate > > > \src\NHibernate\Transaction > > > \AdoNetWithDistrubtedTransactionFactory.cs:line 42 > > > > > This occurs when I use SQL Server 2005 as the db. When I use > > > postgresql I get an "InvalidOperationException" in NHibernate saying > > > that I cannot call disconnect when a transaction is in process, and > > > then the whole process crashes. > > > > > Here is my MessageModule. Is there something different I should be > > > doing? Is anyone else using NH, AR, and Rhino with RSB? > > > > > public class UnitOfWorkMessageModule : IMessageModule > > > { > > > public void Init(ITransport transport) > > > { > > > transport.MessageArrived += transport_MessageArrived; > > > transport.MessageProcessingCompleted += > > > transport_MessageProcessingCompleted; > > > } > > > > > void transport_MessageProcessingCompleted > > > (Rhino.ServiceBus.Impl.CurrentMessageInformation arg1, Exception arg2) > > > { > > > if (UnitOfWork.IsStarted) > > > UnitOfWork.Current.Dispose(); > > > } > > > > > bool transport_MessageArrived > > > (Rhino.ServiceBus.Impl.CurrentMessageInformation arg) > > > { > > > UnitOfWork.Start(); > > > return false; > > > } > > > > > public void Stop(ITransport transport) > > > { > > > transport.MessageArrived -= transport_MessageArrived; > > > transport.MessageProcessingCompleted -= > > > transport_MessageProcessingCompleted; > > > } > > > } > > > > > Thanks! > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Rhino Tools Dev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rhino-tools-dev?hl=en -~----------~----~----~----~------~----~------~--~---
