Service Fabric allows you to listen to arbitrary endpoints (irrespective of the protocol, messaging framework etc..) by funneling everything through CreateCommunicationListener method which returns a listener (discussed at a great length here). The listener itself have basic life cycle control primitives exposed to to you as Initialize, OpenAsync, CloseAsync & Abort methods.
The included libraries (with Service Fabric) further extends into Wcf specific listening with 1:1:1 mapping (one service replica: one Wcf Host: one Wcf endpoint) which works well in a lot of the situations.
The problem happen when this mapping is not found (for example):
- Legacy services that were built to have 1 host: multiple endpoints). and you need to migrate as is (some refer to inter contract shared state in Wcf world) .
- Legacy services that uses *weird* routing that having 2 contracts in the same service host won’t work (for those Wcf fans out there you know what i am talking about). They have to work on a different Wcf hosts.
While helping in migrating an existing Wcf system last week I encountered some of the above. Enter Wcf multi point listener which allow you to do the following:
1- Map multiple Wcf endpoints/contracts/hosts to a single replica.
2- Migrate Wcf Services as-is to Service Fabric based hosting.
3- Migrate Wcf Services (and use Service Fabric State) in them.
4- Control over how listening address are created.
5- control over how bindings are assigned.
6- Control over Wcf Hosts, Wcf Endpoints as they are being created. to add behaviors, dispatchers etc..
7- Support for ICommunicationXXXX Service Fabric interfaces which recycles Wcf channels between callers. Maximum of 1 channel type per host/per endpoint is created at any single time.
8- The service fabric client implementation implements disposable pattern and will abort all open Wcf channels upon Dispose or GC.
The code is open source and published on Git Hub here: https://github.com/khenidak/ServiceFabricMultiPointWCFListener
Feel free to clone, use, change.
till next time