ServiceProxy.Create<IService>() can already create proxy for different interface, why a factory is provided? How to choose ServiceProxy or ServiceProxyFactory?
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@cppcraze Thanks for the feedback. We are actively investigating and will get back to you soon.
@vturecek @aljo-microsoft could either of you provide some insight into this question?
@cppcraze
Could you clarify how the following referenced document content is confusing:
"
Service proxy lifetime
Service proxy creation is a lightweight operation, so you can create as many as you need. Service proxy instances can be reused for as long as they are needed. If a remote procedure call throws an exception, you can still reuse the same proxy instance. Each service proxy contains a communication client used to send messages over the wire. While invoking remote calls, internal checks are performed to determine if the communication client is valid. Based on the results of those checks, the communication client is re-created if needed. Therefore, if an exception occurs, you do not need to re-create ServiceProxy.
Service proxy factory lifetime
ServiceProxyFactory is a factory that creates proxy instances for different remoting interfaces. If you use the API ServiceProxyFactory.CreateServiceProxy to create a proxy, the framework creates a singleton service proxy. It is useful to create one manually when you need to override IServiceRemotingClientFactory properties. Factory creation is an expensive operation. A service proxy factory maintains an internal cache of the communication client. A best practice is to cache the service proxy factory for as long as possible.
"
So explicitly do you need to: "override IServiceRemotingClientFactory properties."?
Thanks @aljo-microsoft
@cppcraze any update on this?
sorry for not replying yesterday. The documentation is clear on what those two classes can do. I am trying to understand the guideline or design of these two classes, given that they can achieve same purpose that is creating the proxy instance of remoting interface. So when I should use ServiceProxy, when i should use ServiceProxyFactory.
@cppcraze
Explicitly if you do not have a known reason to: "override IServiceRemotingClientFactory properties", then you would use ServiceProxy.
@MicahMcKittrick-MSFT
ok, fine, if you guys can't answer the question, just close it.
@cppcraze the answer as Alex states is
"Explicitly if you do not have a known reason to: "override IServiceRemotingClientFactory properties", then you would use ServiceProxy."
In addition, as you are a MSFT Employee there are DLs you are reach out to for design assistance if you require it. Feel free to ping me offline and I can provide you with those alias's
yeah, thanks Micah. feel free to close.