Durable Session Client Template
The Cluster-SOA Debugger for Windows HPC 2008 R2 includes a template for creating a Durable Session Client. This type of client uses the
BrokerClient objects to support reliable calculations and client interaction models such as file and recollect. The template includes references to the necessary HPC namespaces and the outline of the code that is used to create and start a durable session on a Windows HPC 2008 R2 cluster.
In this topic:
When you create a new project using the Durable Session Client template, a series of dialog boxes appear that prompt you to specify a cluster head node and to add a service reference. When you add a service reference to a project in Visual Studio, the WCF client objects (client proxies) are created automatically. To support asynchronous calls and the BrokerClient object, you must select the following advanced options for the service reference:
Generate asynchronous operations. This option generates methods such as
EndGetDatain the resulting WCF client object.
Always generate message contracts. This option implements the
GetDataResponsedata types for the
After you provide this information, the following updates are made automatically to the solution:
The following updates are made to Program.cs:
A reference to your service is included in the
Your head node is specified in the
The interface for the service that you specified is used to create the broker client objects. (For example:
(BrokerClient<IYourService> client = new BrokerClient<IYourService>(session, binding).)
The service contract name is updated in the client configuration file (app.config). In app.config, the first
endpointelement defines the HPC SOA Debugging Endpoint. The
contractattribute specifies the service contract name.
The Windows HPC Pack 2008 R2 SDK includes support for creating reliable sessions and client interaction models such as file and recollect, batch, and shared session clients. These scenarios are supported by additions to the
Microsoft.Hpc.Scheduler.Session namespace, including the BrokerClient class and the DurableSession class. Many of the new supported models do not require changes the service code, just to the client.
DurableSession supports reliable computations. When a
DurableSession is created, request and response messages are persisted by the broker node so that in event of client or network failure, requests and responses are not lost. Clients can attach to a session with the same session ID to retrieve responses using the
AttachSession() method is a non-blocking call that retrieves responses, but does not cause the broker node to release the responses (so they can be retrieved again in the case of failure). This allows you to attach to a crashed session to retrieve responses, or to restart a file and recollect session to retrieve responses.
BrokerClient supports decoupled sending and receiving of typed messages to and from a WCF service. The
BrokerClient constructor wraps your WCF client (client proxy) to override standard call behavior and create a message-based proxy. In the standard WCF client, a single call sends and receives responses. In the
BrokerClient, sending and receiving are separate calls.
The following table describes the elements of the Durable Session Client template:
|Properties||Includes attributes that define information about your assembly.|
Set information about your assembly (such as title and description) in this file.
See HPC Class Library.
|Service References||When you include a service reference in your project, Visual Studio creates files that are required for the proxy class. A Durable Session Client project requires that the service reference is created with the following advanced options selected:|
- Generate asynchronous operations
- Always generate message contracts
If the message contract is not generated, you will see an error indicating that the message contract can’t be found and that a placeholder file was created. (Client.cs)
|Defines binding configuration settings for the client.|
Specify the service contract name in this file.
|This is a template for a service configuration file that defines binding configuration settings for the service. You can copy this template to your service library project to use instead of the default App.config file.|
Specify the service name and the service contract name in this file. Optionally, adjust the timeout settings.
|Provides a placeholder for the WCF client proxy object if you do not include a service reference or if the message contract can’t be found when adding the reference. For durable session clients, this file implements the |
You will need to replace the two occurrences of
|Provides a template for the client code. The template includes placeholders for the name of the head node, the name of the service, and the WCF client object.|
This file includes the code to perform the following tasks:
- Specify a head node
- Specify the service name
- Create and start a session on the cluster
- Store the session ID
- Create a broker client instance and send requests
- Create a new broker client instance that attaches to the same session to retrieve responses