Spring升级后 RabbitMQ自动声明问题

Spring升级后 RabbitMQ自动声明问题,第1张

Spring升级后 RabbitMQ自动声明问题

RabbitAdmin的initialize()方法
spring-rabbit-2.0.3 版本可以采用

		@SuppressWarnings("rawtypes")
		Collection collections = this.declareCollections
			? this.applicationContext.getBeansOfType(Collection.class, false, false).values()
			: Collections.emptyList();
		for (Collection collection : collections) {
			if (collection.size() > 0 && collection.iterator().next() instanceof Declarable) {
				for (Object declarable : collection) {
					if (declarable instanceof Exchange) {
						contextExchanges.add((Exchange) declarable);
					}
					else if (declarable instanceof Queue) {
						contextQueues.add((Queue) declarable);
					}
					else if (declarable instanceof Binding) {
						contextBindings.add((Binding) declarable);
					}
				}
			}
		}

Spring-rabbit-2.2.18版本

private void processDeclarables(Collection contextExchanges, Collection contextQueues,
			Collection contextBindings) {

		Collection declarables = this.applicationContext.getBeansOfType(Declarables.class, false, true)
				.values();
		declarables.forEach(d -> {
			d.getDeclarables().forEach(declarable -> {
				if (declarable instanceof Exchange) {
					contextExchanges.add((Exchange) declarable);
				}
				else if (declarable instanceof Queue) {
					contextQueues.add((Queue) declarable);
				}
				else if (declarable instanceof Binding) {
					contextBindings.add((Binding) declarable);
				}
			});
		});
	}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5695998.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存