简体   繁体   English

WCF或Windows服务以实现MSMQ

[英]WCF or windows service to implement MSMQ

I have a client server setup where i am sending the messages to the server over http(I am using WCF service hosted as windows service.)In my current setup as I have seen some messages are lost when the connection is down between client and server ,for the sake of reliability i have decided to use MSMQ.So the client sends the messages to the queue and the server continuously polls the queue I need some design decision to be taken before i will developing. 我有一个客户端服务器设置,我通过http将消息发送到服务器(我正在使用作为Windows服务托管的WCF服务。)在当前设置中,因为我看到客户端和服务器之间的连接断开时某些消息丢失了,出于可靠性考虑,我决定使用MSMQ。因此,客户端将消息发送到队列,服务器不断轮询队列,因此在开发之前我需要做出一些设计决定。 Which one would be the best bet windows service or wcf service(hosted as windows service) ? 哪一个是最佳的Windows服务或wcf服务(作为Windows服务托管)?

Are there any advantages apart from windows service which WCF has if i have to develop such a service where all it has to do is continuusly read messages from the queue and does some processing.I would be using a private queue which is transnactional . 如果我必须开发WCF所需要的所有服务,那就是从WCF获得Windows服务以外的任何优势,而该服务所要做的就是连续从队列中读取消息并进行一些处理。我将使用事务性的专用队列。

I would suggest avoiding writing code that directly integrates with MSMQ and instead using an existing service bus to do that for you (like NServiceBus or MassTransit). 我建议避免编写直接与MSMQ集成的代码,而应使用现有的服务总线为您完成此工作(例如NServiceBus或MassTransit)。 Rolling-your-own messaging layer may work for the simplest of systems but as requirements change over time you will need a fuller featured service bus. 滚动式消息传递层可能适用于最简单的系统,但是随着需求随时间的变化,您将需要功能更全面的服务总线。 The service buses that I mentioned do the following things in a developer friendly way: 我提到的服务总线以对开发人员友好的方式执行以下操作:

  • Messaging patterns (fire-and-forget, request-response, publish subscribe) 消息传递模式(即发即弃,请求-响应,发布订阅)
  • Message serialization 消息序列化
  • Message routing 邮件路由
  • Failure/Retry logic (ie a message handler is supposed to update a database, but the database is down how do you handle this?) 失败/重试逻辑(即消息处理程序应该更新数据库,但是数据库已关闭,您如何处理?)
  • Long running processes (also called sagas) 长时间运行的流程(也称为sagas)

These are just a few of the things you will be writing before long if you go the roll-your-own route. 如果您走了自己的路线,这些只是不久之后您将要写的一小部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM