1

我正在尝试按照本文档中的说明配置 RabbitMQ 延迟消息交换:https ://github.com/rabbitmq/rabbitmq-delayed-message-exchange/

下面是我尝试将 README 中的代码示例翻译成 clojure/langohr。

(let [conn (langohr.core/connect {:host "localhost" :port 61666})
      ch (langohr.channel/open conn)]
  (langohr.exchange/declare ch "my-exchange" "x-delayed-message"
                            {"x-delayed-type" "direct"}))

可悲的是,当我运行它时,我收到此错误:

ShutdownSignalException channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - Invalid argument, 'x-delayed-type' must be an existing exchange type, class-id=40, method-id=10)  com.rabbitmq.client.impl.ChannelN.asyncShutdown (ChannelN.java:509)

查看 rabbit_exchange_type_delayed_message 插件的源代码,我可以看到我{"x-delayed-type" "direct"}的 case 语句中的默认处理程序似乎落空了。

https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/blob/543efef2555338c46f776a89df3ee134066221e2/src/rabbit_exchange_type_delayed_message.erl#L72

我不知道为什么会发生这种情况,或者如何解决它。

4

1 回答 1

2

看起来您需要将选项映射包装在另一个:arguments映射中。这是显示使用解构绑定作为映射的调用的langohr.exchange/declare代码。.exchangeDeclarearguments

(let [conn (langohr.core/connect {:host "localhost" :port 61666})
      ch (langohr.channel/open conn)]
  (langohr.exchange/declare ch "my-exchange" "x-delayed-message"
                            {:arguments {"x-delayed-type" "direct"}}))
于 2018-02-14T04:57:01.487 回答