tags:

views:

407

answers:

4

I need WCF service with 3 endpoints

  1. High
  2. Normal
  3. Low

Most of messages will come through Normal and Low Endpoints. If Message on High will appear it have to be processed asap.

Does anyone knows how to do it ???

A: 

I guess you'll have to implement that priority yourself.

If a high priority comes in you'll have to stop everything else (save its state or something) and start doing whatever it is that needs to be done.

just a thought

sebastian
+2  A: 

Why not run two separate endpoint processes, one for low/normal and a separate one for high. You could even locate it on separate (better?) hardware if you have the capacity. Otherwise if you have to do it in a single process, then a Priority Queue seems to me what you'll need.

endian
+2  A: 

The easiest way I can think of would be to deploy your service twice: one with the low/medium endpoints and then a completely different instance with the high endpoint. As Endian said in his answer (which I voted for BTW), you could physically seperate them, but you could also have them running on the same box is you who two instances using different ports. This is the way I would do it (or REALLY push for) if I had to do it.

You're other (unappealing) option is to create a custom channel that is capable of manipluating the messages and putting them in a seperate "VIP" line, and a corresponding operation behavior that can pull from the "VIP" line when the service operation is ready to recieve a message. This doesn't really buy you anything over the first option because all you're doing is making sure your service runs in one "set" of service instances. I'm guessing that in your situation this doesn't buy you much.

As far as stopping and re-starting the service is a higher priority request comes in, there be dragons. I would avoid it if at all possible. If not, you might want to consider creating your service as a WF workflow and using some of it's process start/stop functionality, but you'll still need some a custom channel and some custom behavior to make that work. At this point, you might want to think about BizTalk.

James Bender
+1  A: 

You should take a look at this great two part series from Michele Leroux Bustamante in MSDN Magazine:

Building a WCF Router, Part 1 and Building a WCF Router, Part 2

Part 1, in particular, would be interesting to you:

Sometimes it is useful to introduce an intermediary or router service between a client and a target service to receive messages that flow between them and perform additional activities such as logging, priority routing, online/offline routing, load balancing, or to introduce a security boundary. When such an intermediate service is introduced, it becomes necessary to tweak some addressing and message filtering behaviors to accommodate.

[my emphasis added]

She also has the related source code available on her blog.

Mike L