For some reason WCF penalizes you heavily if you let it perform auto-open.  In 
fact, everything becomes sequential and throughput drops dramatically.  Can you 
inject Lazy<IService1>, Lazy<IService2> to help mitigate your concern.  You can 
probably also use the TypedFactoryFacility and inject Func<IService1>, 
Func<IService2> as well.

On Jun 27, 2011, at 1:11 PM, Nicolás Sabena wrote:

> Hi. I noticed in the WcfClientActivator code that the channel is
> opened as soon as it is requested. The reason is attributed to this
> post:
> 
> ///   Always Open the channel before being used to prevent
> serialization of requests.
> ///   
> http://blogs.msdn.com/wenlong/archive/2007/10/26/best-practice-always-open-wcf-client-proxy-explicitly-when-it-is-shared.aspx
> 
> Somehow that doesn't feels entirely correct. It might be a good thing
> to do if one expects the channel to be used with a long standing
> lifestyle (singleton?).
> I have a different use case: an MVC web app for front-end that
> communicates with a back-end app via WCF.
> Through injection, the controllers asks for one or more components
> that might be used in the actions they contain.
> Not all the actions use all components, so this can happen:
> 
> // constructor
> public Controller(IService1 service1, IService2 service2)
> {
> }
> 
> // some action
> public ActionResult Action1()
> {
>  service1.DoSomething();
>  // service2 never gets used
> }
> 
> In this example, service2's channel gets opened even if not used. I
> know this could be avoided if using factories, but it would certainly
> make things a lot more complicated.
> 
> Would it be wrong to expect the activator NOT to open the channel
> automatically in this cases?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Castle Project Development List" 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-devel?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" 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-devel?hl=en.

Reply via email to