4

This is the design I need : My design idea.

enter image description here

Is the 'Subscriber' design a good idea for the 'orange' part of the service ?

Clients needs to connect to the service to perform 'read' and 'write' operations, and they also need to get notifications (in a PUSH manner) from the service.

At the beginning I thought that the service that provides the 'read' and 'write' functionialliyy will be able to send notifications also (via a background thread), but then I understood that 'CallBack' is only used when a service needs to call functions on the client as a reponse for a client's request . Meaning - the service cannot initiate a call to the client. So is the 'Subsciber' design the correct way to go at this ?

tom redfern
  • 30,562
  • 14
  • 91
  • 126
John Miner
  • 893
  • 1
  • 15
  • 32

1 Answers1

1

So short answer is yes - using publish/subscribe pattern is very well known model. It helps with decoupling consumers from publishers. Devil is in the implementation details and how much complexity can you handle and what are you willing to trade in your design.

You could start with WCF duplex channel implementation if you are willing to accept it's trade offs (must be WCF client, you own client and service) and limitations (clients directly coupled, network topology limitations).

If the limitations of duplex channel is not to your liking then you can look into using something like MSMQ or NServiceBus to facilitate pub/sub requirements. You can take it to the next level with Windows Azure AppFabric Service Bus.

Duplex can send messages to the client independently not just when call from client arrives.

Duplex is not durable - you got to recover from channel failure when client goes away or there are any communication problems. Securing duplex can be tricky. You have to have WCF client/service on both sides. You have to be aware of your network topology.

You have 2 different bound contexts (systems). One is for the clients to send commands and query and the another one is for publishing interesting events to who ever want's to listen to these events.

EDIT - What if some of the clients are iOS devices ? Would using a DUPLEX pose a problem ? Can you develop an iOS app that communicates to a WCF service via a DUPLEX channel?

Answer: See this SO WCF duplex connection on iPhone? and What should I know when developing interoperable WCF web service?

Community
  • 1
  • 1
Petar Vučetin
  • 3,555
  • 2
  • 22
  • 31
  • Hi ! Thanks for the answer. So you recommend to indeed have 2 services ? one for the 'Pull' functions and one for the 'Push' functions ? and if so - can you elaborate a bit more about the limitations of the DUPLEX ? How are clients coupled and what limitations are on network topology ? I looked at the link you sent - it is called 'List-Based Publish-Subscribe' but I don't see any list. When the price needs to be updated - it seems like an event is raised, that calls all the registered clients (how can this be if it is 'PerSession' ? shouldn't the service be a Singleton ?). – John Miner Apr 20 '12 at 23:06
  • And also - it seems like the service is calling the client directly, not as a response. I thought that CallBack means that the service can call a function on a client ONLY IN RESPONSE to something the client has sent, not independently sending messages to clients. – John Miner Apr 20 '12 at 23:07
  • Thanks ! What if some of the clients are iOS devices ? Would using a DUPLEX pose a problem ? Can you develop an iOS app that communicates to a WCF service via a DUPLEX channel ? – John Miner Apr 21 '12 at 13:55