【发布时间】:2018-02-08 01:03:39
【问题描述】:
我想创建来自rabbitMQ plugin 的延迟交换。
一开始我尝试使用弹簧活页夹,如我所见,delayed-exchange 标志可用:
spring:
cloud:
stream:
bindings:
delayed-ex:
group: update-delayed
contentType: application/json
consumer:
max-attempts: 1
rabbit:
bindings:
delayed-ex:
consumer:
transacted: true
auto-bind-dlq: true
republish-to-dlq: true
delayed-exchange: true
requeue-rejected: false
不幸的是,这个配置让我创建了简单的topic 交换,没有任何标志。
我可以使用以下方法创建 bean:
@Bean
public CustomExchange delayedExchange() {
final Map<String, Object> args = new HashMap<>();
args.put("x-delayed-type", "topic");
return new CustomExchange("delayed-ex", "x-delayed-message", true, false, args);
}
它正在使用当前配置,但它给了我关于我想要覆盖的现有交换的堆栈跟踪:
原因:com.rabbitmq.client.ShutdownSignalException:通道错误;协议方法:#method(reply-code=406,reply-text=PRECONDITION_FAILED - 不等价的 arg 'type' 用于在 vhost '/' 中交换 'delayed-ex':收到 'topic' 但当前是 ''x-delayed-message '', class-id=40, method-id=10)
另一件事(不知道是不是问题)我想让消费者和生产者在同一个服务中,只是为了为我的消息提供缓冲区。
另外,我检查了delayed-exchange 标志的来源,发现这个标志完全没有做任何事情(我错了吗?),因为没有调用来自AbstractExchange 的isDelayed 方法。
是否可以声明类型为x-delayed-message 的延迟交换并通过配置来完成,而不是声明bean?我也想删除那个堆栈跟踪
【问题讨论】: