来自PHP的同步AMQP [英] Synchronous AMQP from PHP

查看:99
本文介绍了来自PHP的同步AMQP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHP是否可以将AMQP视为RPC服务,并发送消息并阻塞直到返回答复?有没有很好的例子,是否有任何库都以易于使用的方式包装了这些功能?

Can PHP treat AMQP like an RPC service, and send a message and block until a reply is returned? Are there any good examples of this, and do any libraries wrap such functionality up in an easy-to-use way?

我希望具有代理消息传递系统的灵活性,但可以保护Web层免于需要了解其异步特性.

I'd like to have the flexibility of a brokered messaging system, but shield the web tier from needing to know about its asynchronous nature.

推荐答案

当然可以.查看RPC样式的请求如何在系统中流动:

Sure, absolutely. Look at how an RPC-style request flows around a system:

  1. 发出请求
  2. 请求者现在阻止等待对该请求的答复

这完全可以通过AMQP之类的异步消息系统实现.您只需要自己进行RPC关联:

That's completely implementable with an asynchronous message system like AMQP. You just need to do the RPC correlation yourself:

  1. 在其中具有唯一ID的异步消息中发送您的请求(这不会阻止)
  2. 从消息传递系统接收消息并阻止,直到您收到具有相同唯一ID的消息(这意味着您刚刚收到了回复)

RabbitMQ 是AMQP经纪人,提供

RabbitMQ, an AMQP broker, offers documentation online on how to do exactly this.

这篇关于来自PHP的同步AMQP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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