odolbeau/rabbit-mq-admin-toolkit

RabbitMQ 管理工具包

v5.2.0 2021-12-21 09:32 UTC

README

Build Status Latest Stable Version Latest Unstable Version

安装

推荐通过 Composer 安装 RabbitMQ 工具。需要安装 odolbeau/rabbit-mq-admin-toolkit

$ composer require odolbeau/rabbit-mq-admin-toolkit

使用方法

您可以使用以下命令创建/更新 vhost

vendor/bin/rabbit vhost:mapping:create conf/vhost/events.yml

您可以使用选项更改所有连接信息。运行 ./console vhost:create -h 以获取更多信息。

即使 vhost 已存在,您也可以启动 vhost 创建。不会删除任何内容(并且不会影响工作者)。

配置

您可以使用以下参数来配置交换机

  • with dl:如果设置为 true,当前 vhost 中的所有队列将自动配置为具有 dl(名称为:{queueName}_dl)。当然,将创建 dl 交换机。
  • with_unroutable:设置为 true 时,将创建一个 unroutable 交换机,并将所有其他交换机配置为将无法路由的消息移动到该交换机。该 unroutable 交换机是一个扇出交换机,并将一个 unroutable 队列绑定到它。

示例

my_vhost_name:

    permissions:
        my_user:
            configure: amq\.gen.*
            read: .*
            write: .*
            
    parameters:
        with_dl: true # If true, all queues will have a dl and the corresponding mapping with the exchange "dl"
        with_unroutable: true # If true, all exchange will be declared with an unroutable config

    exchanges:
        my_exchange:
            type: direct
            durable: true
            with_unroutable: true #if true, unroutable exchange will be created (if not already set as global parameter)

        my_exchange_headers:
            type: headers
            durable: true

    queues:
        my_queue:
            durable: true
            delay: 5000 #create delayed message queue (value is in milliseconds)
            bindings:
                - 
                    exchange: my_exchange
                    routing_key: my_routing_key
                - 
                    exchange: my_exchange
                    routing_key: other_routing_key
                    
        another_queue:
            durable: true
            with_dl: false
            retries: [25, 125, 625]
            bindings:
                - 
                    exchange: my_exchange_headers
                    x-match: all
                    matches: {header_name: value, other_header_name: some_value}

许可证

本项目以 MIT 许可证发布。有关详细信息,请参阅捆绑的 LICENSE 文件。

变更日志

1.x 和 2.0.x 之间的 BC 兼容性中断

  • 简短绑定语法不再受支持。
  # old syntax
  queues:
    my_queue:
        bindings:
            - my_exchange:my_routing_key

必须替换为

  # new syntax
  queues:
    my_queue:
        bindings:
            - 
                exchange: my_exchange
                routing_key: my_routing_key