PHP 驱动程序中的 AMQP 清除
为什么我必须在此方法中指定队列名称? http://www.php.net/manual/en/amqpqueue.purge.php 我使用构造函数来定义队列名称,如下所示:
$this->queue = new AMQPQueue($connection);
$this->queue->declare($queueName, AMQP_DURABLE);
ii 不需要在 get、ack、consume 等方法中定义队列名称
Why do i have to specify the queue name in this method?
http://www.php.net/manual/en/amqpqueue.purge.php
i use constructor for define queue name like this:
$this->queue = new AMQPQueue($connection);
$this->queue->declare($queueName, AMQP_DURABLE);
ii is not neccessary to define queue name in methods like: get, ack, consume
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是界面设计不当的一个例子。看起来 PHP
AMQPQueue
类的设计者将许多东西集中到一个地方,而不是将它们分成单独的类。与来自
get
、ack
和consume
等消息消费相关的方法与特定队列相关,并且(如您所观察到的)与传递的队列相关联到构造函数中。其他非队列特定的方法(purge
、delete
等)是更具管理性的方法,属于在构造时不采用队列名称的单独类。That's an example of a badly designed interface. It looks like the designers of the PHP
AMQPQueue
class lumped a number of things together into one place rather than split them up into separate classes.Methods relating to message consumption from like
get
,ack
andconsume
relate to a specific queue and are (as you observed) tied to the queue passed in to the constructor. The other methods which are not queue specific (purge
,delete
, etc) are more administrative methods and belong in a separate class which does not take a queue name at construction time.