WCF4 routing with reliable sessions and callbacks
I'll start with an explanation of what I'm trying to do, and the environment / circumstances involved.
I'm working with a pre-existing WCF service (hosted as a windows service) that I've implemented using .NET 4. The service utilizes net.tcp and reliable sessions, as well as callbacks to the client application. The WCF service and client application operate on the same network domain (we'll call it Domain_A), and work properly.
Existing:
(Client [Domain_A]:) ---[request]--> (WCF Svc [Domain_A])
(Client [Domain_A]:)<--[callback]--- (WCF Svc [Domain_A])
The new functionality that I'm attempting to implement is that of a routing service (via WCF 4). There will be an identical copy of the WCF service running on Domain_A that will also run on Domain_B. The required ports for the net.tcp and mex endpoints have been opened between the two computers on each domain, and I am able to successfully access each service's metadata from the opposite domain.
What I'm unsure about, is what route (architecturally) I should take as far as routing the service requests are concerned. Certain requests made by the client can only be replied to by the service on Domain_A, and others can only be replied to by the service on Domain_B. The destination service is (or can be) determined by a parameter that is passed (from the client) with each service call. Also, the client application will only be run from Domain_A.
Desired functionality:
(Client [Domain_A]:) ---[request]-->(Routing Svc [Domain_A]) ---[request]-->( (WCF Svc [Domain_A]) OR (WCF Svc [Domain_B]) )
(Client [Domain_A]:) <--[callback]--- (Routing Svc [Domain_A])<--[callback]--- ( (WCF Svc [Domain_A]) OR (WCF Svc [Domain_B]) )
My first qestion: What would be the best route for implementing the "Desired functionality" above as far as routing goes (filtering strategy, endpoint / contract type, etc.)? I'm new to the routing service, and have not been able to find a clear / concise answer or example that fits my requirements.
Second question: In addition to the filtering question, can anyone point me to an example of a WCF4 routing service that uses reliable sessions and callbacks? I can't seem to find much other than a quick mention of the IDuplexSessionRouter. If the IDuplexSessionRouter endpoint is the way to go, I've been unable to find an example that implements callbacks.
Thanks in advance 开发者_JAVA百科for any help or information. Please let me know if I need to clarify anything above.
Check this Microsoft sample for dynamic routing (can be found in this SkyDrive link, under WCF4WhatsNew.rar\WCF4WhatsNew\03_DynamicRoutingRules\).
The sample redirect to an alternate service every 5 seconds. Change the sample to your desired routing algorithm.
P.S: The question is a bit tl;dr. I suggest you to be more specific and use text formatting to emphasize the important parts. Otherwise, you'll receive many more tumbleweeds.
精彩评论