dqmg80654 2018-08-13 16:45
浏览 40

如何在RabbitMQ中使用wildacard队列名发送消费任务?

I have publisher, which send info into different queues in RabbitMQ

$this->_channel->queue_declare('qwe.w', FALSE, TRUE, FALSE, FALSE, FALSE);
$this->_channel->queue_declare('qwe.q', FALSE, TRUE, FALSE, FALSE, FALSE);
$this->_channel->basic_publish(
    $message, 
    '', 
    'qwe.q'
);
$this->_channel->basic_publish(
    $message, 
    '', 
    'qwe.w'
);

How I can consume them using wildcard queue name? Something like (code below doesn't work)

$this->_channel->basic_consume('qwe.#', '', FALSE, TRUE, FALSE, FALSE, 'function_name');

Important thing that I need - don't lose messages, even if consumer offline.

  • 写回答

1条回答 默认 最新

  • dtry54612 2018-08-13 17:36
    关注

    RabbitMQ does not support wildcard queue names. However, it does support Topic Exchanges, which give you effectively the same thing.

    Under this topology, you would publish with the routing key you're already using, but you would publish to the topic exchange (there is a default exchange called amq.topic, or you can declare your own). Then, you create the queue for the subscriber. Finally, you bind the queue to the topic exchange using the wildcard routing mechanism that you're trying to use for the subscription.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题