Good Strategy for Message Queuing?

前端 未结 3 1792
闹比i
闹比i 2020-12-24 03:52

I\'m currently designing an application which I will ultimately want to move to Windows Azure. In the short term, however, it will be running on a server which I will host m

相关标签:
3条回答
  • 2020-12-24 04:38

    If you have Azure in mind, perhaps you should start straight on Azure as the APIs and semnatics are significantly different between Azure queues and any of MSMQ or SSB.

    A quick 3048 meters comparison of MSMQ vs. SSB (I'll leave a custom table-as-queue out of comparison as it really depends how you implement it...)

    • Deployment: MSMQ is a Windows component, SSB is a SQL compoenent. SSB requires a SQL instance to store any message, so disconencted clients need access to an instance (can be Express). MSMQ requires deployment of MSMQ on the client (part of OS, but optional install).
    • Programmability: MSMQ offers a fully fledged, supported, WCF channel. SSB offers only an experimental WCF channel at http://ssbwcf.codeplex.com
    • Performance: SSB will be significantly faster than MSMQ in transacted mode. MSMQ will be faster if let operate in untransacted mode (best effort, unordered, delivery)
    • Queriability: SSB queues can be SELECTE-ed uppon (view any message, full SQL JOIN/WHERE/ORDER/GROUP power), MSMQ queues can be peeked (only next message)
    • Recoverability: SSB queues are integrated in the database so they are backed up and restored with the database, keeping a consitent state with the application state. MSMQ queues are backed up in the NT file backup subsytem, so to keep the backup in sync (coherent) the queue and database have to be suspended.
    • Transactions (since every enqueue/dequeue is always accompanied by a database update): SSB is fully integrated in SQL so dequeueing and enqueueing are local transaction operations. MSMQ is a separate TM (Transaction Manager) so queue/dequeue has to be a Distributed Transaction operation to enroll both SQL and MSMQ in the transaction.
    • Management and Monitoring: both equaly bad. No tools whatsoever.
    • Correlated Messages processing: SSB can block processing of correlated message by concurent threads via built-in Conversation Group Locking.
    • Event Driven: SSB has Activation to launch stored procedures, MSMQ uses Windows Activation service. Similar. SSB though has self load balancing capalities due to the way WAITFOR(RECEIVE) and MAX_QUEUE_READERS interact.
    • Availability: SSB piggybacks on the SQL Server High Availability story, it can work either in a clustered or in database miroring environment. MSMQ rides the Windows clustering story only. Database Mirroring is much cheaper than clustering as a HA solution.

    In addition I'd add that SSB and MSMQ differ significantly at the level ofthe primitive they offer: SSB primitive is a conversation, while MSMQ primitive is a message. Think TCP vs. UDP semantics.

    0 讨论(0)
  • 2020-12-24 04:44

    Pick a queue back end that works for you, or that is better suited to your environment. @Remus has given a great comparison between MSMQ and SSB. MSMQ is going to be the easier one to implement, but has some notable limitations, while SSB is going to feel very heavy as its at the other end of the spectrum.

    Have It Your Way
    To minimize the rework from you applications, abstract the queues access behind an interface, and then provide an implementation for the queue transport you ultimately decide to go with. When its time to move to Azure, or another queue transport, you just provide a new implementation of your interface.

    You get to control the semantics of how you want to interact with the queue to give a consistent usable API from your applications.

    A rough idea might be:

    interface IQueuedTransport
    {
      void SendMessage(XmlDocument);
      XmlDocument ReceiveMessage();
    }
    
    public class MSMQTransport : IQueuedTransport {}
    public class AzureQueueTransport : IQueuedTransport {}
    

    You may not be building the be-all queuing transport, just what meets your needs. If you work with Xml, pass xml. If you work in byte arrays, pass byte arrays. :)

    Good luck!
    Z

    0 讨论(0)
  • 2020-12-24 04:44

    Use Win32 Mailslots. They will be reliable on a single server, are easy to implement, and do not require any extra software.

    0 讨论(0)
提交回复
热议问题