Search code examples
c#wcfarchitectureerror-handlingmsmq

Decoupling MSMQ By Sending Messages Through a WCF service


I have several .Net applications (not yet built) that need to send error messages, warnings, alerts, heartbeats, etc. to a database so they can be viewed in an alarm summary dashboard. This can't slow the apps down too much. It has to be fast. I want a way to prioritize certain messages so they are displayed right away in the dashboard.

I am thinking that MSMQ is the way to go because there might be a ton of messages coming in and you can make several queues.

Would it be faster to make my apps send the messages directly to MSMQ? Or, would it be faster to send them to a WCF service with NetMSMQBinding?

If I send the messages directly to MSMQ then the apps are tightly coupled to MSMQ and if I want to scrap MSMQ later and use something else I will be screwed. I don't want to have to make changes to the apps once they are in the wild every time the alarm summary app changes.

If I send the messages to a WCF service with the NetMSMQBinding then I still tightly-couple my apps to MSMQ, right?

This alarm summary application could be huge, effecting every app in the entire system and it has to be done correctly.


Solution

  • I'm just finishing a huge project for the company where I work that is similar to yours.

    It relies purely on WCF using NetTcpBinding and persisting all the information on a Sql Server database.

    The main WCF service is the responsible for persisting the information to the database. Others wcf services return the data to the clients that need it (a 32" touchscreen hanging in our wall, desktop gadgets, smartphones).

    There's a common library that contains the contract definitions and all the client related stuff that is used by all the apllications here (10+). All this applications log everything against the wcf service (always in async operations): exceptions, warnings, heartbeats, even debug information. The quantity of clients here is not huge, it's about 60 pc's running 1 or 2 apps at the same time.

    The dashboard is a WPF application that keep contacting a wcf service to know if there are updates based on the priority and then display them in a nice UI.

    Between the 60+ clients we have 15 RTU that send temperature (ºC) and pressure (bars) of natural gas pipes from 3 different cities to the same server, this information is received by a windows service via Tcp and then send to the wcf service (on the same server). All this data is critical!! We even have another windows service that keeps querying a wcf service to find important events and send SMS to the persons related to that type of event.

    Soooooo, IMO wcf is a great technology for achieving your goals!