Menu

Service- and client identification

asy proger

Address, Binding, Operation- and Data Contracts

WCF uses address, binding and contract configuration elements.
AsyncWcfLib reduces the configuration burden:

  • Addresses may be created programmatically for service or client instances.

  • Default binding for all endpoints is defined in class WcfDefault.
    Services and clients must use the same binding.
    The binding greatly affects communication speed. Ws2007HttbBinding is 4 times slower than basicHttpBinding.
    TcpBinding is used as default. HttpBinding needs port reservation under Windows 7.
    Individual binding for each port may be set when calling ActorOutput.LinkOutputToRemoteService and ActorInput.LinkInputToNetwork.

  • Operation Contract is fixed by AsyncWcfLib:
    Services and Clients use "AsyncWcfLib.Basic.IWcfBasicContractSync". This is an synchronous interface, returning a response after handling the request.
    The contract may be used by partners running on .NET 3.5 - 4.5 or Mono.
    The library handles the different asynchronous patterns for clients and services.

  • Data Contract consists of all classes used as messages. Most of them are created by the library user.
    These classes are deployed in form of an assembly-dll at the client and the service side, see [AsyncWcfLib package diagram].

Service and client configuration names

When using AsyncWcfLib, service and client configuration files are optional.
If you want to use an App.config file, the name "AsyncWcfLib.ServiceContract" is used for service configuration.
When using a special client configuration, the clientName (given in the constructor) is used to find the endpoint configuration in the config file.

ActorInput (service-) network identification

The full service URI is assembled from the following components:

  • Hostname: Computer running the application containing the service.
  • TCP portnumber : Automatically handled by AsyncWcfLib when not added to the hostname (separated by ":").
  • '/AsyncWcfLib/': A constant defined in class WcfDefault.WsNamespace. It is recommended to change this constant to your company and projectname.
  • ActorInputName : The servicename itself may contain several more naming components specifying the unique position or purpose of this actor in a plant.
    The name may be created programmaticaly from other configuration elements specifying the purpose of the application and the actor instance.
    Typically every plant type has its own naming convention adapted to its unique requirements.

In order to lookup ActorInputs by WcfRouter, each ActorInputName must be unique in a plant.
Actors may be moved from one host to another or may be moved from one application into another. Clients will automatically discover the moved actors because a lookup at the router will return the correct URI containing hostname and TCP port.

ActorOutput (client-) network identification

ActorOutput identification is used to identify the connected client by the service.
Using the ActorOutput identification, the service is able to match newly connected clients to their client state before a network communication interrupt.
It is also used to trace(log) source and destination of message exchange.

The unique identification of an ActorOutput contains some of the following components:

  • ApplicationName
  • ApplicationInstanceNumber (supports running several processes of the same application on the host or in the plant)
  • Hostname
  • ProcessId (on the host)
  • ActorOutputName (in the application)

The following three session modes are used for applications containing actors.
The session mode defines the level of recovery after connection loss.
It also defines the name of the tracefile written by class WcfTrcPluginFile.

1. Temporary host session

Used e.g. for graphical user interfaces.
The application instance number must be set to 0. Change the implementation of WcfDefault.IsProcessIdUsed to adapt this behaviour to your own needs.
Upon disconnect the session data is disposed on the service side. Therefore no recovery is possible after unexpected network interrupts.

ActorOutput identification:

  • Applicationname (entry assembly name).
  • Hostname.
  • ProcessId (####) as given by the operating system.
  • ActorOutputName as given in the constructor.

Tracefilename:

  • Applicationname.####.Hostname.trace.txt
    Change the creation of a tracefilename in WcfDefault.GetAppIdentification().

2. Permanent host session

When the application instance number is below 100, the number must be unique on the host only, not the whole plant.
Change the implementation of WcfDefault.IsAppIdUniqueInPlant to adapt this behaviour to your own needs.
If you will, data referencing the partner actor may be kept even when the connection is disconnected or the partner has shut down.
After restart of clients, services or hosts, the original partner is mapped to its session data in the still running actor.

ActorOutput identification:

  • Applicationname (entry assembly name).
  • Hostname.
  • Application instance number (##): Hostwide unique for this application type.
  • ActorOutputName as given in the constructor.

Tracefilename:

  • Applicationname-##.Hostname.trace.txt

3. Permanent plant session

A plantwide unique application instance number may be advantageous in some cases (e.g. central, host independent configuration).
In this mode AsyncWcfLib supports backup applications having same application instance number but running on seperate hosts.
The backup application reclaims connection and state after shutdown of the first application (-host).
As the hostname is not part of the ActorOutput identification, the backup actor may take over at the state, where the failed actor has left the still running partner.

ActorOutput identification:

  • Applicationname (entry assembly name).
  • Application instance number (###): Plantwide unique for this application type.
    The instance number must be 100 or greater to indicate uniqueness.
    Change the implementation of WcfDefault.IsAppIdUniqueInPlant to adapt this behaviour to your own needs.
  • ActorOutputName as given in the constructor.

Tracefilename:

  • Applicationname-###.trace.txt

Related

Wiki: Actors
Wiki: AsyncWcfLib package diagram
Wiki: Home
Wiki: Implement a client using AsyncWcfLib
Wiki: Implement a service using AsyncWcfLib
Wiki: Run AsyncWcfLib.Test1
Wiki: Run AsyncWcfLib.Test2
Wiki: Run AsyncWcfLib.Test3

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.