Home » Microsoft » 70-518 » What should you do?
You are designing a Windows application by using Microsoft .NET Framework 4 and Microsoft Visual Studio 2010. The business logic layer of the application is implemented by using Windows Communication Foundation (WCF).
You create a duplex bidirectional WCF service that contains a single operation. The service operation sends the result back to the client application by using a two- way callback operation.
You plan to design a service interaction strategy.
You need to ensure that deadlocks are prevented.
What should you do?
A. Configure the CallbackBehaviorAttribute attribute to use the Reentrant or Multiple concurrency mode in the callback class.
B. Configure the ServiceBehaviorAttribute attribute to use the Reentrant or Multiple concurrency mode in the service class.
C. Configure the ServiceBehaviorAttribute attribute to use the Synchronization context in the service class.
D. Configure the CallbackBehaviorAttribute attribute to use the Synchronization context in the callback class.
Correct Answer: B
Explanation/Reference:
Explanation
Esta pregunta puede que le falte informacion.
La pregunta se ve desde el lado del cliente. es decir ServiceBeahviourAttribute. y como es el unico que tiene una propiedad se acepta. El callbackbehaviour será del lado del WS.
Explanation/Reference:
Designing Concurrency for Web Services
You can control whether WCF Web Services are single-threaded or multithreaded. If they are multithreaded, you have to plan to write code to perform locking and to work around deadlock conflicts.
Two factors determine whether a WCF web service is single-threaded or multithreaded: instancing and concurrency. Instancing (defined by the ServiceBehavior attribute’s Instance ContextMode property) defines the conditions in which WCF creates a new process:
¦¦ Single WCF uses a single instance for the web service, regardless of the number of calls or users.
¦¦ PerSession WCF uses a separate instance for each user session, which means that each user gets his own instance unless a user creates multiple sessions.
¦¦ PerCall WCF uses a separate instance for each call, which might mean that multiple instances are created for a single user.
For each instance mode, WCF Web Services support three different concurrency modes (defined by the ServiceBehavior attribute’ ConcurrencyMode property for inbound connections, or the CallbackBehavior attribute’ ConcurrencyMode property for callbacks):
¦¦ Single Each instance context is allowed to have a maximum of one thread processing messages in the instance context at a time. Other threads will be blocked until they time out or the thread completes, but you do not have to write code to deal with threading issues.
¦¦ Multiple Each service instance can have multiple threads processing messages concurrently. You must create a thread-safe service to use the Multiple concurrency mode.
¦¦ Reentrant Each service instance processes one message at a time, but accepts re-entrant operation calls. The service accepts these calls only when it is calling out through a WCF client object. The Reentrant concurrency mode is only relevant for PerSession instancing.
If you set InstanceContextMode to Single and ConcurrencyMode to Single, the web service always will be single-threaded, messages always will be processed in the order that they are Objective 3.5: Design for a Concurrent Multiuser Environment Chapter 3 207 received, and there never will be any risk of concurrency problems. However, there could be performance problems because the web service will wait until one request is complete before processing another request.