Link to home
Start Free TrialLog in
Avatar of WestcountryBusiness
WestcountryBusiness

asked on

Is WCF the right choice for cross application communication

I'm working on a new project that involves automating a process.  The software to control the automated process will run as a Console Application on a dedicated PC.  Occassionally that automated process may be to raise an alert that manual intervention is required.  

A user on another PC running a Windows forms application will have a 'monitoring form' open.  I'm investigating the best way for the software running the application to control the automated task to communicate with the Windows forms application running elsewhere.

Both PCs will be on the same network and both will have access to the same SQL Server database as well.  My first thought was to write to an SQL table and have the client software poll that repeatedly, but on reading up I discovered the Windows Communication Foundation.

I've spent a few hours reading about this, but not sure how I can get the automated process / console application) to initiate communication with the client (the WinForms application).  

It looks like the WCF server would need to be a separate project to both, so can I use it to route messaging between the two applications?  

I've spend a couple of hours reading up and happy to spend more time researching (not asking anyone to do my job for me) but can anyone confirm whether WCF is the right approach for this or, if not, what the preferred means of inter-application communication should be.  Thanks
Avatar of it_saige
it_saige
Flag of United States of America image

Yes, WCF is the right approach for this.  To provide some guidance, the automated process isn't going to initiate the communication, in other words the automated process is not the subscriber, rather the automated process is the publisher.  As such the automatic process only needs to hold onto a list of subscribers.  Then the automatic process can initiate events on the subscribers that are in the list.

http://www.codeproject.com/Articles/663333/Understanding-Events-in-WCF

-saige-
Avatar of WestcountryBusiness
WestcountryBusiness

ASKER

Sorry for the delay replying.  Thanks, that's very helpful.  I'll try and take a good look at that article tomorrow but it does appear to offer the solution.  I didn't know whether my automated process could also be the communication server (or publisher) so I though I'd need to implement so form of client to client comms routed via a server process.

If, as appears, the automated process can also be a Communication Publisher then that should do it ... hopefully.  I'll find out over the next few days!
OK, so I've a working solution running now which will do what I need, so thanks for the help getting me started.  I do have one outstanding question that I haven't yet resolved though.

My Automated Processes is now also the Host for the WCF Service and my client PCs register/subscribe fine, so I have the callbackchannels to communicate back through - all good.

However, in order for my Automated Process to initiate communication to the client PCs, I also need to configure it to connect (to itself) as a client.  So in my service contract I need to define a "RaiseAlert" procedure (for the Automated Processes to call to trigger the callback to clients alerting them that attention is needed) and an "AlertRespondedTo" procedure (for the clients to call to trigger a callback to the Automated Process to say all OK).

That's fine, but it would seem neater to me if the Automated Process that is running the Host could initiate the RaiseAlert procedure without first having to connect to itself as a client.

Is that possible?  It works the way it is now so I have a solution but would like to check I'm not missing something here.
ASKER CERTIFIED SOLUTION
Avatar of it_saige
it_saige
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks - I have already gone through that example in getting this far.  Hadn't thought about multiple callback chanels though, so will look into that.