Sorry guys. My NH transaction factory was switched to the old one
(switched when was trying to figure out NH + DTC issue). With the
default it all seems to work correctly.

On 22 окт, 18:59, Mike Nichols <[email protected]> wrote:
> @Vadim
> Have you tried to run this without NH transactions? I pulled out my message
> module that was doing something similar.
> I am only using ambient transactions and things seem to work just fine with
> the AdoNetWithDistributed transation factory as the default in NH 2.1 +.
> Initially I thought I would need explicit NH transactions but even using two
> session factories everything Just Works. Using NH Prof shows me the
> transactional boundaries are just what I expect.
>
>
>
> On Thu, Oct 22, 2009 at 4:04 AM, Ayende Rahien <[email protected]> wrote:
> > Send me a patch for this
>
> > On Thursday, October 22, 2009, Vadim Kantorov <[email protected]>
> > wrote:
>
> > > It'd be cool in the light of the NHibernate + DTC issue
>
> > > On 21 окт, 23:29, Ayende Rahien <[email protected]> wrote:
> > >> We can probably offer another event, before we commit the DTC
>
> > >> On Wed, Oct 21, 2009 at 7:26 PM, Vadim Kantorov <
> > [email protected]>wrote:
>
> > >> > Keeping in mind this crazy issue:
>
> > >> >http://groups.google.ru/group/nhibernate-development/browse_thread/th.
> > ..
> > >> > I tried to use native NH transactions everywhere just in case. I
> > >> > thought creating a message module would be a solution.
> > >> > Unfortunately, my module doesn't work correctly.
>
> > >> > public class NhMessageModule : IMessageModule
> > >> >        {
> > >> >        readonly ISessionFactory factory;
>
> > >> >                public NhMessageModule(ISessionFactory factory)
> > >> >                {
> > >> >                        this.factory = factory;
> > >> >                }
>
> > >> >                public void Init(ITransport transport)
> > >> >                {
> > >> >                        transport.MessageArrived += OpenSession;
> > >> >                        transport.MessageProcessingCompleted +=
> > >> > DisposeOfSession;
> > >> >                }
>
> > >> >                public void Stop(ITransport transport)
> > >> >                {
> > >> >                        transport.MessageArrived -= OpenSession;
> > >> >                        transport.MessageProcessingCompleted -=
> > >> > DisposeOfSession;
> > >> >                }
>
> > >> >                private bool OpenSession(CurrentMessageInformation arg)
> > >> >                {
> > >> >                        var session = factory.OpenSession();
> > >> >                        session.BeginTransaction();
>
> > >> >                        CurrentSessionContext.Bind(session);
>
> > >> >                        return false;
> > >> >                }
>
> > >> >                private void DisposeOfSession(CurrentMessageInformation
> > >> > arg1,
> > >> > Exception arg2)
> > >> >                {
>
> > >> >                        if (CurrentSessionContext.HasBind(factory))
> > >> >                        {
> > >> >                                var session =
> > >> > CurrentSessionContext.Unbind(factory);
>
> > >> >                                if (session.Transaction != null &&
> > >> > session.Transaction.IsActive)
> > >> >                                        session.Transaction.Commit();
>
> > >> >                                session.Dispose();
> > >> >                        }
> > >> >                }
> > >> >        }
>
> > >> > It fails with an SqlException
> > >> > Message: The COMMIT TRANSACTION request has no corresponding BEGIN
> > >> > TRANSACTION.
> > >> > Stack trace:
> > >> >   at System.Data.SqlClient.SqlConnection.OnError(SqlException
> > >> > exception, Boolean breakConnection)
> > >> >   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
> > >> > exception, Boolean breakConnection)
> > >> >   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning
> > >> > (TdsParserStateObject stateObj)
> > >> >   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
> > >> > SqlCommand cmdHand
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to