In CastleServiceLocator.cs, the code which resolves message consumers looks 
like this:

            return (from h in container.Kernel.GetAssignableHandlers(type)
                   select (IHandler)new DefaultHandler(h.Service, 
h.ComponentModel.Implementation, () => 
h.Resolve(CreationContext.CreateEmpty())));

The empty CreationContext references the NoTrackingReleasePolicy, which 
prevents message consumers (and their dependencies) from being cleaned up 
after message consumption (although RSB calls 
container.Kernel.ReleaseComponent(item), it has no effect since the object 
is not tracked).

In my scenario, a few message consumers need to call a WCF service, and 
receive a proxy to this service via constructor injection. The consumers 
themselves are simple classes that do not require cleanup. The proxy must 
be closed, however, and I wanted to implement the logic as an 
IDecommissionConcern. Unfortunately, the above problem prevents the cleanup 
code from being invoked.

I have implemented a fix, which creates a CreationContext that references 
the ReleasePolicy configured for the container:

                   () => h.Resolve(new CreationContext(h, 
container.Kernel.ReleasePolicy, type, null, null, null))

It seems to be working and tests are green. I'm curious, however, what was 
the original reason for using an empty CreationContext in the resolving 
code and whether the reason still stands (and I'm missing something)?

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino Tools Dev" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rhino-tools-dev/-/4BmEA9QBD58J.
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