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