栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

Spring升级后 RabbitMQ自动声明问题

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);
				}
			});
		});
	}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/695854.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号