I have developed the following.  Seems to work.  I am still having issues
under heavy load, but I think it¹s something else.

If it looks okay, I will submit a patch.  I was thinking I might also add a
config option ³isWcf².

public class WcfThreadScopeInfo : AbstractThreadScopeInfo
{
    public override Stack CurrentStack
    {
        [MethodImpl(MethodImplOptions.Synchronized)]
        get
        {
            var current = OperationContext.Current;
            if (current == null)
            {
                var message = "WcfThreadScopeInfo: Could not access
OperationContext.Current";
                throw new ScopeMachineryException(message);
            }

            var extension = current.Extensions.Find<StackExtension>();
            if (extension == null)
            {
                extension = new StackExtension();
                OperationContext.Current.Extensions.Add(extension);
            }

            if (extension.Stack == null)
            {
                extension.Stack = new Stack();
            }

            return extension.Stack;
        }
    }

    private class StackExtension : IExtension<OperationContext>
    {
        public Stack Stack { get; set; }
        public void Attach(OperationContext owner) { }
        public void Detach(OperationContext owner) { }
    }
}


On 1/28/09 8:49 AM, "Ayende Rahien" <[email protected]> wrote:

> I think that you need to write one that will use the WCF call context to keep
> the session
> 
> On Wed, Jan 28, 2009 at 9:46 AM, Tim Scott <[email protected]>
> wrote:
>> Castle trunk has three concrete implementations of IThreadScopeInfo:
>> ThreadScopeInfo, WebThreadScopeInfo and HybridThreadScopeInfo.  I assume that
>> because I do not have isWeb="true" I am using the ThreadScopeInfo.  Should I
>> add isWeb="true", and do you think that will solve it?  Do I need to write a
>> custom IThreadScopeInfo?
>> 
>> 
>> 
>> On 1/28/09 7:49 AM, "Ayende Rahien" <[email protected]
>> <http://[email protected]> > wrote:
>> 
>>>   <activerecord default-lazy="true">
>>> 
>>> This is where you define your scope semantics
>>> isWeb="true", or hybrid.
>>> I don't know if we have a scope impl for Call Context, though.
>>> 
>>> On Wed, Jan 28, 2009 at 8:46 AM, Tim Scott <[email protected]
>>> <http://[email protected]> > wrote:
>>>> Okay, I lied.  Here is the AR config:
>>>> 
>>>>   <activerecord default-lazy="true">
>>>>     <config>
>>>>       <add key="connection.driver_class"
>>>> value="NHibernate.Driver.SqlClientDriver" />
>>>>       <add key="dialect" value="NHibernate.Dialect.MsSql2005Dialect" />
>>>>       <add key="connection.provider"
>>>> value="NHibernate.Connection.DriverConnectionProvider" />
>>>>       <add key="connection.connection_string_name"
>>>> value="MyNamedConnection"  />
>>>>     </config>
>>>>   </activerecord>
>>>> 
>>>> 
>>>> 
>>>> On 1/27/09 9:00 PM, "Ayende Rahien" <[email protected]
>>>> <http://[email protected]>  <http://[email protected]> > wrote:
>>>> 
>>>>> Where is the connections tring?
>>>>> 
>>>>> On Tue, Jan 27, 2009 at 9:54 PM, Tim Scott <[email protected]
>>>>> <http://[email protected]>
>>>>> <http://[email protected]> > wrote:
>>>>>> The only config I have for AR is in Binsor:
>>>>>> 
>>>>>> component "active_record_repository", IRepository, ARRepository
>>>>>> 
>>>>>> component "active_record_unit_of_work", IUnitOfWorkFactory,
>>>>>> ActiveRecordUnitOfWorkFactory:
>>>>>>     assemblies = (Assembly.Load("MyApp.MyCore"),)
>>>>>> 
>>>>>> Is this what you are asking for?
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> On 1/27/09 8:43 PM, "Ayende Rahien" <[email protected]
>>>>>> <http://[email protected]>  <http://[email protected]>
>>>>>> <http://[email protected]> > wrote:
>>>>>> 
>>>>>>> The problem is likely with the scope that you selected for AR
>>>>>>> What is your configuration?
>>>>>>> 
>>>>>>> On Tue, Jan 27, 2009 at 7:46 PM, Tim Scott <[email protected]
>>>>>>> <http://[email protected]>
>>>>>>> <http://[email protected]>
>>>>>>> <http://[email protected]> > wrote:

The app uses Rhino.Commons and its Repository<T>, underlying which is
NHibernate.  I use ActiveRecord attributes for mapping only.  The
application is a Rhino.Commons' UnitOfWorkApplication.

My service classes are decorated with [Transactional] and the methods with
[Transaction].

I know you are not a Rhino Commons expert and so this might not be enough
detail, and maybe it's some Rhino Commons issue?



On 1/27/09 6:01 PM, "hammett" <[email protected] <http://[email protected]>
<http://[email protected]>  <http://[email protected]> > wrote:

>
> Not with this amount of information. What's the machinery (AR, NH,
> other)? What kind of app? Have you configured a custom activity
> manager?
>
>
> On Tue, Jan 27, 2009 at 3:51 PM, Tim Scott <[email protected]
<http://[email protected]>  <http://[email protected]>
<http://[email protected]> >


> wrote:
>>
>> Any thoughts on how this exception might occur?
>>
>>
>> On Jan 27, 5:26 pm, hammett <[email protected] <http://[email protected]>
<http://[email protected]>  <http://[email protected]> > wrote:
>>> This comment is stalled. The TM is now per thread, so there's nothing
>>> being shared across threads.
>>>
>>>
>>>
>>> On Tue, Jan 27, 2009 at 1:07 PM, Tim Scott <[email protected]
<http://[email protected]>  <http://[email protected]>
<http://[email protected]> >


>>> wrote:
>>>
>>>> I am using AutomaticTransactionManagement in my app, and I am doing
>>>> some stress testing.  All is well until I reach a fairly heavy load;
>>>> then I get the following exception:
>>>
>>>> System.ArgumentException: transaction
>>>> Parameter name: Tried to dispose a transaction that is not on the
>>>> current active transaction
>>>>   at Castle.Services.Transaction.DefaultTransactionManager.Dispose
>>>> (ITransaction transaction)
>>>>   at
>>>> Castle.Facilities.AutomaticTransactionManagement.TransactionInterceptor.Int
<http://Castle.Facilities.AutomaticTransactionManagement.TransactionInterceptor.
Int>  
<http://Castle.Facilities.AutomaticTransactionManagement.TransactionInterceptor.
Int>  
<http://Castle.Facilities.AutomaticTransactionManagement.TransactionInterceptor.
Int>  
<http://Castle.Facilities.AutomaticTransactionManagement.TransactionInterceptor.
Int> 
>>>> ercept
>>>> (IInvocation invocation)
>>>
>>>> I decided to have a look at the source code to see if I can figure out
>>>> what might be happening.  The following comment the summary for
>>>> DefaultTransactionManager jumped out at me:
>>>
>>>> TODO: Ensure this class is thread-safe
>>>
>>>> Has anyone else seen this behavior?  Might I be doing something wrong
>>>> in my app?
>>>
>>>> Not sure it it's relevant but I am also using Rhino.Commons and
>>>> UnitOfWorkApplication.
>>>
>>> --
>>> Cheers,
>>> hammetthttp://hammett.castleproject.org/ <http://hammett.castleproject.org/>
<http://hammett.castleproject.org/>  <http://hammett.castleproject.org/>
<http://hammett.castleproject.org/>
>>>
>>
>
>




>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>> 
>>>> 
>>> 
>>> 
>>> 
>>> 
>> 
>> 
> 
> 
> > 
> 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to