WCF - NetMsmqBinding 与 NetTcpBinding [英] WCF - NetMsmqBinding vs NetTcpBinding

查看:16
本文介绍了WCF - NetMsmqBinding 与 NetTcpBinding的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读这篇文章 http://weblogs.asp.net/spano/archive/2007/10/02/choosing-the-right-wcf-binding.aspx 选择绑定选项.

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.

我对

离线或断开交互,选择NetMsmqBinding

offline or disconnected interaction, choose the NetMsmqBinding

这是否意味着即使服务没有运行仍然使用该服务的客户端?

Does that mean the even if service is not running still client using the service ?

你能分享一些实时的例子吗?

Can you share some real time example ?

推荐答案

这 2 个绑定完全不同.

The 2 bindings are radically different.

  • NetTcpBinding 可以被认为是一种 MS 专有格式(通常是二进制),在概念上类似于 RPC(例如,可用于替换 .NET 远程处理).它是同步的,即客户端和服务器必须同时在线,并且客户端(几乎)立即收到响应.

  • NetTcpBinding can be thought of as an MS proprietary format (usually binary) similar in concept to RPC (e.g. can be used to replace .NET Remoting). It is synchronous, i.e. both client and server must be online at the same time, and the client receives a response (almost) immediately.

MSMQ 是微软的一个面向消息的中间件解决方案,它围绕异步队列——例如如果客户端发送消息时目标服务器离线,则消息将在客户端上排队,直到服务器重新上线.每个队列只是一种方式,虽然双向通信可以通过从服务器返回到客户端的第二个队列来实现.发送 WCF MSMQ 消息需要在客户端上安装 MSMQ 服务.队列中的消息可以有一个传递超时",否则将被放置在适用的死信队列中.

MSMQ is a Message Oriented Middleware solution by Microsoft, which revolves around asynchronous queues - e.g. 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. 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. Messages on the queue can have a delivery 'timeout' else will be placed on an applicable dead letter queue.

现实世界的例子:

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

TL;DR

这是否意味着即使服务没有运行仍然使用该服务的客户端

Does that mean the even if service is not running still client using the service

是的.如果MSMQ在本地运行,客户端会立即得到返回成功响应(表示消息已经排队).然而,这并不意味着该消息已被服务器成功接收.

Yes. If MSMQ is running locally, the client will get an immediate return successful response (indicating that the message has been queued). This does not however mean that the message has been successfully received by the server.

这篇关于WCF - NetMsmqBinding 与 NetTcpBinding的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆