What are two possble ways to achieve this goal?

A WCF service code is implemented as follows. (Line numbers are included for reference only)

01 [ServiceContract]
02 [ServiceBehavior(InstanceContextMode =
03 InstanceContextMode.Single)]
04 public class CalculatorService
05 {
06 [OperationContract]
07 public double Calculate(double op1, string op, double op2)
08 {
09 }
10 }

You need to increase the rate by which clients get the required response from the service.
What are two possble ways to achieve this goal? (Each correct answer presents a complete solution. Choose two.)

A WCF service code is implemented as follows. (Line numbers are included for reference only)

01 [ServiceContract]
02 [ServiceBehavior(InstanceContextMode =
03 InstanceContextMode.Single)]
04 public class CalculatorService
05 {
06 [OperationContract]
07 public double Calculate(double op1, string op, double op2)
08 {
09 }
10 }

You need to increase the rate by which clients get the required response from the service.
What are two possble ways to achieve this goal? (Each correct answer presents a complete solution. Choose two.)

A.
Change the service behavior to the following:
[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single, ConcurrencyMode=ConcurrencyMode.Multiple)]

B.
Change the service behavior to the following.
[ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)]

C.
Require the clients use threads, the Parallel Task Library, or other mechanism to issue service calls in parallel.

D.
Require the clients to use async operations when calling the senvice.

Explanation:
The ConcurrencyMode property interacts with some other settings. For example, if the InstanceContextMode value is set to Single
the result is that your service can only process one message at a time unless you also set the ConcurrencyMode value to Multiple.

InstanceContextMode Enumeration
PerSession A new InstanceContext object is created for each session.
PerCall A new InstanceContext object is created prior to and recycled subsequent to each call. If the channel does not create a session this value behaves as if it were PerCall.
Single Only one InstanceContext object is used for all incoming calls and is not recycled subsequent to the calls. If a service object does not exist, one is created.

Note For singleton lifetime behavior (for example, if the host application calls the ServiceHost constructor and passes an object to use as the service),
the service class must set InstanceContextMode to InstanceContextMode.Single, or an exception is thrown when the service host is opened.

ConcurrencyMode Enumeration
(http://msdn.microsoft.com/en-us/library/system.servicemodel.concurrencymode.aspx)



Leave a Reply 1

Your email address will not be published. Required fields are marked *