简体   繁体   English

WCF - NetMsmqBinding与NetTcpBinding

[英]WCF - NetMsmqBinding vs NetTcpBinding

I was going through this article http://weblogs.asp.net/spano/archive/2007/10/02/choosing-the-right-wcf-binding.aspx to choose Binding options. 我正在阅读这篇文章http://weblogs.asp.net/spano/archive/2007/10/02/choosing-the-right-wcf-binding.aspx来选择Binding选项。

where i got an unusual doubt of what is mean by 我对这是什么意思有一个不同寻常的怀疑

offline or disconnected interaction, choose the NetMsmqBinding 脱机或断开连接,选择NetMsmqBinding

Does that mean the even if service is not running still client using the service ? 这是否意味着即使服务没有运行仍然使用该服务的客户端?

Can you share some real time example ? 你能分享一些实时的例子吗?

The 2 bindings are radically different. 2个绑定完全不同。

  • NetTcpBinding can be thought of as an MS proprietary format (usually binary) similar in concept to RPC (eg can be used to replace .NET Remoting ). NetTcpBinding可以被认为是MS专有格式(通常是二进制),在概念上与RPC类似(例如,可以用来代替.NET Remoting )。 It is synchronous, ie both client and server must be online at the same time, and the client receives a response (almost) immediately. 它是同步的,即客户端和服务器必须同时在线,并且客户端(几乎)立即收到响应。

  • MSMQ is a Message Oriented Middleware solution by Microsoft, which revolves around asynchronous queues - eg if the destination server is offline when the client sends a message, the message will be queued on the client until the server comes back online. MSMQ是Microsoft的面向消息的中间件解决方案,它围绕异步队列 - 例如,如果目标服务器在客户端发送消息时处于脱机状态,则消息将在客户端上排队,直到服务器重新联机。 Each queue is one way only, although bidirectional communication can be achieved via a second queue back from server to client. 尽管可以通过从服务器到客户端的第二个队列实现双向通信,但每个队列只是一种方式。 Sending WCF MSMQ messages requires that the MSMQ Service be installed on the client. 发送WCF MSMQ消息要求在客户端上安装MSMQ服务。 Messages on the queue can have a delivery 'timeout' else will be placed on an applicable dead letter queue. 队列中的消息可以具有传递“超时”,否则将被置于适用的死信队列中。

Real world examples: 现实世界的例子:

  • I would use NetTcpBinding with binary serialization for high performance, synchronous communication needs between a Microsoft WCF client and server, eg uploading files, media etc where Xml would not be useful (otherwise, I would use wsHttpBinding for synchronous Xml / SOAP messaging) 我会使用NetTcpBinding和二进制序列化来实现Microsoft WCF客户端和服务器之间的高性能,同步通信需求,例如上传文件,媒体等,其中Xml不会有用(否则,我会使用wsHttpBinding进行同步Xml / SOAP消息传递)
  • I would use MSMQBinding with DTC enabled to ensure reliable messaging between 2 or more systems (eg financial), with at least one of the endpoints being in .Net, and a 'compatable' server (not necessarily WCF , eg BizTalk , or other EAI hubs or ESB buses which have adapters for MSMQ , eg Bridges exist between MSMQ and MQSeries ). 我将使用MSMQBinding了DTC的MSMQBinding来确保2个或更多系统(例如财务)之间的可靠消息传递,其中至少一个端点位于.Net中,以及“兼容”服务器(不一定是WCF ,例如BizTalk或其他EAI具有适用于MSMQ适配器的集线器或ESB总线,例如, MSMQ and MQSeries之间存在桥接器。 Messages would typically be in an Xml format. 消息通常采用Xml格式。

TL;DR TL; DR

Does that mean the even if service is not running still client using the service 这是否意味着即使服务没有运行仍然使用该服务的客户端

Yes. 是。 If MSMQ is running locally, the client will get an immediate return 如果MSMQ在本地运行,客户端将立即返回 successful response 成功的回应 (indicating that the message has been queued). (表示邮件已排队)。 This does not however mean that the message has been successfully received by the server. 但这并不意味着服务器已成功接收消息。

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

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