开发者

Recommended message bus architecture for publishing client events

What's the recommended messaging architecture for the following scenario:

  • Multiple workstations running a WinForms client
  • Clients must reliably notify two (or more) Windows Services of an event

Initially we wanted to avoid configuring MSMQ on the client workstations, so we created a web service. This proved difficult to configure, and then I read that publishing NServiceBus messages from a web application is not recommended.

开发者_运维技巧

Is the best practice to:

  • Have the clients call a web service, which sends (not publishes) a message to a Windows service, which publishes the message?
  • Send (not publish) the message directly from the client applications to a remote queue on a server, from which a Windows service publishes the message?
  • Other?

Currently I am trying to implement this using NServiceBus, but hopefully the answer is bus-agnostic.

Edit:

If clients simply send (not publish) to a remote queue, does MSMQ need to be configured (or even installed) on the client workstations? In that case what happens if the remote queue is unreachable?


You can expose an NServiceBus endpoint as a WCF service.

From the bottom of the NServiceBus and WCF page:

public class MyService : NServiceBus.WcfService<MyCommand, MyErrorCodes>
{
    ...
}

Take a look at that. You should be able to have your client applications connect to the WCF services to drop messages. You can configure the WCF service with http, net.tcp, or whatever WCF transport works for you.

This service would then NOT be a web application, even if it uses the HTTP transport (although you might have to pick a nonstandard port). It would be a Windows service exposing a web service interface. It would be fine to publish messages from here. This gives you the freedom from having to configure MSMQ on all the clients but still a lot of the NServiceBus ease and flexibility.

Of course if scalability of this service is a concern, you may want to have an IIS-hosted web service with load balancing. In that case, create a normal WCF web service that sends a message to a NServiceBus.Host.exe endpoint installed as a Windows service, and then publish events from that Windows service.


I think the clients should message the servers directly as your option two suggests. Though you would have to configure msmq on the client workstations. Why do you not want to do this?

This has the benefit of durability end-to-end.

I notice you talk about sending vs publishing, however I can't see anything in your scenario which warrants using NSB pub-sub.

FYI it's almost always the best thing to send to remote queues and read from local queues.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜