Kudos to you Diego, that fixed it!

On Apr 16, 1:05 am, Diego Mijelshon <[email protected]> wrote:
> NHibernate transactions will enlist in ambient transactions. And you **must**
> use transactions for NH data access.
> Try that and tell us if it works.
>
>    Diego
>
>
>
> On Thu, Apr 15, 2010 at 11:55, Iain <[email protected]> wrote:
> > I haven't really looked much into the session.BeginTransaction(). I
> > need use nHibernate with MSMQ and WCF and my feeling is that
> > session.BeginTransaction will not hock into the WCF transaction. Am I
> > wrong? I can't find much on it.
>
> > On Apr 15, 11:59 pm, Diego Mijelshon <[email protected]> wrote:
> > > I'm not big on ambient transactions... but your I think there's a problem
> > > with your code.
> > > IMO, it should look like this:
>
> > >        using (TransactionScope tx =
> > > new TransactionScope(TransactionScopeOption.RequiresNew))
> > >        using (ISession session = sessions.OpenSession())
> > >        using (ITransaction nhtx = session.BeginTransaction())
> > >        {
> > >            W s = new W();
> > >            session.Save(s);
> > >            session.Flush();
> > >            nhtx.Commit();
> > >        }
>
> > > Try it and see if there's any difference.
>
> > >    Diego
>
> > > On Thu, Apr 15, 2010 at 01:48, Iain <[email protected]> wrote:
> > > > Hi All,
>
> > > > I am having a connection leak when we using the ambient transaction,
> > > > and the transaction is aborted. That is, I get the exception:
> > > > System.InvalidOperationException: Timeout expired.  The timeout period
> > > > elapsed prior to obtaining a connection from the pool.  This may have
> > > > occurred because all pooled connections were in use and max pool size
> > > > was reached.
>
> > > > I am guessing something is holding onto a reference to the connection,
> > > > or an internal part of the connection. As adding a watch to following
> > > > and debug breaking within the transaction also causes this issue.
> > > >                ((System.Data.SqlClient.SqlInternalConnectionTds)
> > > > ((System.Data.SqlClient.SqlConnection)
> > > > (session.Connection))._innerConnection)._connectionPool.Count
>
> > > > Is this a known issue or unsupported? Currently our workaround is to
> > > > promote the transaction to a distributed transaction which seems to
> > > > work ok, as per this article:
> > > >http://davybrion.com/blog/2010/03/msdtc-woes-with-nservicebus-and-nhi.
> > ..
>
> > > > Here is the unit test that re-produces the issue:
>
> > > > [Test]
> > > > public void CanUseSystemTransactionsToAbort()
> > > > {
> > > >    for (var i = 0; i < 200; i++)
> > > >    {
> > > >        using (ISession session = sessions.OpenSession())
> > > >        using (TransactionScope tx = new
> > > > TransactionScope(TransactionScopeOption.RequiresNew))
> > > >        {
> > > >            W s = new W();
> > > >            session.Save(s);
> > > >            session.Flush();
> > > >        }
> > > >    }
> > > > }
>
> > > > Cheers,
>
> > > > Iain
>
> > > > --
> > > > 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]<nhusers%[email protected]­>
> > <nhusers%[email protected]<nhusers%252bunsubscr...@googlegroup­s.com>>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/nhusers?hl=en.
>
> > --
> > 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]<nhusers%[email protected]­>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.- Hide quoted text -
>
> - Show quoted text -

-- 
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.

Reply via email to