简体   繁体   English

Azure员工间流程通信

[英]Azure Inter-worker process communication

I am working to port an application which was designed to work in a non-Azure environment. 我正在努力移植一个旨在在非Azure环境中工作的应用程序。 One of the elements of the architecture is a singleton which does not scale, and which I'm hoping to replace w/ multiple worker processes serving the resource that the singleton currently provides. 该体系结构的元素之一是无法扩展的单例,我希望替换为单个单元当前提供的资源的多个工作进程。

I have the necessary changes in place to replace the singleton, and am at the point of constructing the communications framework to provide interconnection from the UI servers to the resource workers and I'm wondering if I should just use a TCP binding on a WCF service or whether using the Azure Service Bus would make more sense. 我已经进行了必要的更改以替换单例,并且正在构建通信框架以提供从UI服务器到资源工作者的互连,我想知道是否应该在WCF服务上使用TCP绑定。还是使用Azure Service Bus更有意义。 The TCP/WCF is easy, but doesn't solve the complete problem: how do I ensure that only one worker processes a UI request? TCP / WCF很简单,但不能解决完整的问题:如何确保只有一个工作进程处理UI请求?

From reading the available documentation, it sounds like the service bus will solve this, but I've yet to see a concrete example of implementation. 通过阅读可用的文档,听起来服务总线将解决此问题,但是我还没有看到具体的实现示例。 I'm hoping someone here can assist and/or point me in the right direction. 我希望这里的人可以帮助和/或为我指明正确的方向。

Seems that Azure Service Bus queues are the right solution for you. 看来Azure Service Bus 队列是适合您的解决方案。

Azure Service Bus can be used in 3 different ways: 可以通过3种不同的方式使用Azure Service Bus:

  • Queues s列
  • Topics 主题
  • Relays 继电器

From windows azure site: 从Windows Azure网站:

Service Bus queues provide one-way asynchronous queuing. 服务总线队列提供单向异步排队。 A sender sends a message to a Service Bus queue, and a receiver picks up that message at some later time. 发送方将消息发送到服务总线队列,而接收方在稍后的时间接收该消息。 A queue can have just a single receiver 队列只能有一个接收者

You can find more info at: http://www.windowsazure.com/en-us/develop/net/fundamentals/hybrid-solutions/ 您可以在以下位置找到更多信息: http : //www.windowsazure.com/en-us/develop/net/fundamentals/hybrid-solutions/

Adding to Davide's answer. 添加到大卫的答案。

Another alternative would be to use Windows Azure Queues . 另一种选择是使用Windows Azure Queues They are designed to facilitate asynchronous communication between web and worker roles. 它们旨在促进Web角色与辅助角色之间的异步通信。 From your web role you push messages into a queue which is polled by your worker roles. 从您的Web角色中,您可以将消息推送到队列中,该队列由您的辅助角色轮询。

Your worker role can "Get" one or more messages from a queue and work on those messages. 您的辅助角色可以从队列中"Get"一条或多条消息并处理这些消息。 When you get a message from a queue, you can instruct the queue service to make those messages invisible to other callers for a certain amount of time (known as message visibility timeout ). 从队列中获取消息时,可以指示队列服务使这些消息在一定时间内对其他呼叫者不可见(称为message visibility timeout )。 That would ensure that only worker role instance get to work on a message. 这样可以确保只有辅助角色实例才能处理消息。

Once the worker role has completed the work, it can simply delete the message. 辅助角色完成工作后,可以简单地删除消息。 If there's an error in processing the message, the message automatically reappears in the queue once the visibility timeout period has expired. 如果处理消息时出错,则可见性超时期限到期后,消息会自动重新出现在队列中。 You may find this link helpful: http://www.windowsazure.com/en-us/develop/net/how-to-guides/queue-service/ . 您可能会发现此链接很有用: http : //www.windowsazure.com/zh-cn/develop/net/how-to-guides/queue-service/

Azure queues are not designed for inter process communication, but inter-application communication. Azure队列不是为进程间通信而设计的,而是为应用程序间通信而设计的。 The message delivery latency is substantial, and delivery timing cannot be guaranteed. 消息传递延迟很长,并且无法保证传递时间。 Websockets or NetTcpBinding is more suitable for applications that talk to eachother in realtime. Websockets或NetTcpBinding更适合于实时相互通信的应用程序。 Although must admit, you get some free stuff with queuez, especially the locking mechanisms. 尽管必须承认,但是您可以通过queuez获得一些免费的东西,尤其是锁定机制。 Just my 2 cents 就是我的2美分

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

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