Hi all. This one might be for Ayende...
I'm trying to use NHibernate with System.Transactions (since Ayende informed me
he put a good deal of work into it). My stack is NServiceBus trunk, NHibernate
trunk, Rhino.Commons trunk, and ActiveRecord trunk.
I'm trying to create a UnitOfWorkMessageModule for NServiceBus, and my code
looks like this:
public class UnitOfWorkMessageModule : IMessageModule
{
public void HandleBeginMessage()
{
UnitOfWork.Start();
}
public void HandleEndMessage()
{
if (UnitOfWork.Current != null)
{
UnitOfWork.Current.Flush();
UnitOfWork.Current.Dispose();
}
}
}
Before HandleBeginMessage, NServiceBus opens a new
System.Transactions.TransactionScope, and after HandleEndMessage it closes the
transaction. However, when I go to dispose of the UnitOfWork I get this
exception:
Failure in HandleEndMessage of message module:
IDL.Core.Facilities.NServiceBus.MessageModules.UnitOfWorkMessageModule
System.InvalidOperationException: Disconnect cannot be called while a
transaction is in progress.
at NHibernate.AdoNet.ConnectionManager.Disconnect() in
d:\oss\nhibernate-trunk\src\NHibernate\AdoNet\ConnectionManager.cs:line 158
at NHibernate.AdoNet.ConnectionManager.Close() in
d:\oss\nhibernate-trunk\src\NHibernate\AdoNet\ConnectionManager.cs:line 124
at NHibernate.Impl.SessionImpl.Close() in
d:\oss\nhibernate-trunk\src\NHibernate\Impl\SessionImpl.cs:line 345
at
IDL.Core.Facilities.NServiceBus.MessageModules.UnitOfWorkMessageModule.HandleEndMessage()
in
D:\dev\idl-trunk\core\IDL.Core\Facilities\NServiceBus\MessageModules\UnitOfWorkMessageModule.cs:line
31
What am I doing wrong here? Is System.Transactions support still too
experimental to use?
Thanks!
Tyler
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" 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/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---