通过 Internet 在 .net 应用程序之间发送数据
我正在通过互联网从 Windows 应用程序向 asp.net Web 服务发送由 xml(每条大约 1-2 KB)组成的小消息。
99% 的情况下,这种方法都可以正常工作,但有时一条消息需要很长的时间才能到达,即 25 - 30 秒,而不是通常的 4 - 5 秒。这种延迟还会导致消息不按顺序到达。
无论如何,我是否可以解决这个问题,以便所有消息都能快速按顺序到达,或者在以这种方式使用网络服务时无法保证这一点?
如果无法解决,我可以请您推荐一个低延迟消息传递框架,该框架可以通过互联网按顺序传递消息。
谢谢。
I am sending small messages consisting of xml(about 1-2 KB each) across the internet from a windows application to a asp.net web service.
99% of the time this works fine but sometimes a message will take an inordinate amount of time to arive, 25 - 30 seconds instead of the usual 4 - 5 seconds. This delay also causes the message to arrive out of sequence.
Is there anyway i can solve this issue so that all the messages arrive quickly and in squence or is that not possible to gurantee when using a web service in this manner ?
If its not possible to resolve can i please get recomendations of a low latency messaging framework that can deliver messages in order over the internet.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
仅使用网络服务这是不可能的。你总会遇到这样的情况:有时某些事情会比“应该”花费更长的时间。这是网络编程的本质,你必须解决它。
我还建议使用 XMPP 来完成类似的事情。请访问 xmpp.org 了解有关标准的信息以及 jabber-net 用于 .Net 的一组客户端库。
Using just webservices this is not possible. You will always run into situations where occasionally something will take much longer that it "should". This is the nature of network programming and you have to work around it.
I would also recommend using XMPP for something like this. Have a look at xmpp.org for info on the standard and jabber-net for a set of client libraries for .Net.
嗯,这有点偏离目标,但是您研究过 XMPP (Jabber) 协议吗?
这是 GTalk 使用的消息系统。使用起来非常简单。唯一的缺点是您需要有状态服务来接收和处理消息。
我也同意@Mat的评论。这是我想到的第一个解决方案,然后我想起我在过去使用 XMPP 来在服务器之间完成快速/小型且可靠的消息。
http://xmpp.org/about-xmpp/
如果您搜索 google,您将轻松找到 .net支持该协议的库。
并且有很多免费的 jabber 服务器。
Well this is a little off target, but have you looking into the XMPP (Jabber) protocol.
It's the messaging system that GTalk uses. Quite simple to use. Only downside to it, is that you will need a stateful service to receive and process the messages.
I also agree with @Mat's comment. It was the first solution that came to mind, then i remembered that I used XMPP in the pas to acomplish fast/ small and reliable messages between servers.
http://xmpp.org/about-xmpp/
if you search google you will easily find .net libraries which support this protocol.
and there are plenty of free jabber servers out there.
确保消息按顺序发送并作为一批一起解析的一种方法是,对 Web 服务进行一次调用,并将所有相互依赖的消息作为一个批次进行处理。
传统上,当您调用 Web 服务时,您并不期望对该 Web 服务的其他调用会按特定顺序发生。听起来您有一个数据需要到达目标应用程序的隐式序列,这让我认为您需要将消息分组在一起并将它们一起发送以确保该顺序。
无论消息传递框架的速度如何,您都无法保证防止出现可能无序发送消息的竞争条件,除非您发送一条数据顺序正确的消息。
One way to ensure your messages are sent in sequence and are resolved as a batch together is to make one call to the webservice with all messages that are dependent on each other as a single batch.
Traditionally, when you make a call to a web service you do not expect that other calls to the web service will occur in a specific order. It sounds like you have an implicit sequence the data needs to arrive in the destination application, which makes me think you need to group your messages together and send them together to ensure that order.
No matter the speed of the messaging framework, you cannot guarantee to prevent a race condition that could send messages out of order, unless you send one message that has your data in the correct order.
如果您通过互联网按顺序发送消息,您将永远不知道消息从一个点到达另一个点需要多长时间。一种可能的解决方案是在每个消息中包含其在序列中的位置,并在每个端点中实现在处理消息之前对消息进行排序的逻辑。如果您收到的消息顺序不正确,您可以等待丢失的消息,或请求另一个端点重新发送该消息。
If you are sending messages in a sequence across internet, you will never know how long will take the message to arrive from one point to another. One possible solution is to include in each message its position in the sequence, and in each endpoint implement the logic to order the messages prior to processing them. If you receive a message out of sequence, you can wait for the missing message, or request to the other endpoint to resend it.