赞
踩
@Bean
public List<Queue> waveUpdateQueues() {
List<Queue> queues = Lists.newArrayList();
List<Warehouse> warehouses = warehouseMapper.queryAllWarehouse();
for(Warehouse warehouse : warehouses){
Queue queue = new Queue(warehouse.getCode()+QueueContent.QUEUE_WAVEUPDATE_NAME, true);
queues.add(queue);
}
return queues;
}
spring-rabbitmq 版本支持:
RabbitAdmin 类中 initialize()
Collection<Collection> collections = this.applicationContext.getBeansOfType(Collection.class, false, false).values();
spring-rabbitmq 2.1.7 版本支持:
RabbitAdmin 类中 initialize()的
processLegacyCollections()方法中,declareCollections 默认值是false【注:此方法备注3.0 移除此方法】
Collection<Collection> collections = this.declareCollections ? this.applicationContext.getBeansOfType(Collection.class, false, false).values() : Collections.emptyList();
可以启动配置类中设置declareCollections为true
@Bean
public RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory){
RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);
rabbitAdmin.setDeclareCollections(true);
return rabbitAdmin;
}
解决集合类型配置方式,可以使用手动RabbitAdmin:
@Bean
public void bindNewChange() {
RabbitAdmin admin = new RabbitAdmin(connectionFactory());
waveUpdateQueues().stream().forEach(queue -> {
admin.declareQueue(queue);
DirectExchange exchange = pushProductToWmsExchange();
admin.declareExchange(exchange);
admin.declareBinding(BindingBuilder.bind(queue).to(exchange).with(queue.getName().split("-")[1]));
});
}
RabbitMQ 队列配置 在网上队列页面直接
Publish message:
Message will be published to the default exchange with routing key WSPL01-pdp-data-execute, routing it to this queue.
使用 Shovel Management 插件做队列同步,如果使用配置源队列到目标队列,default exchange with routing key 是队列名称,
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。