问题描述
我正在阅读这篇文章 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
这是否意味着即使服务没有运行仍然使用该服务的客户端?
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 toRPC
(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 whereXml
would not be useful (otherwise, I would usewsHttpBinding
for synchronousXml
/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 necessarilyWCF
, e.g.BizTalk
, or otherEAI
hubs orESB
buses which have adapters forMSMQ
, e.g. Bridges exist betweenMSMQ and MQSeries
). Messages would typically be in anXml
format.
TL;DR
这是否意味着即使服务没有运行仍然使用该服务的客户端
是的.如果MSMQ
在本地运行,客户端会立即得到返回(表示消息已经排队).然而,这并不意味着该消息已被服务器成功接收.
Yes. If MSMQ
is running locally, the client will get an immediate return (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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!