[英]Spring integration errors after migration to spring 5
我一直在使用 Spring 集成(不同类型的频道)与 Spring 4 一段时间。 在我尝试将我的环境升级到 Spring 5 后,他们停止工作并出现如下错误:
org.springframework.messaging.MessageHandlingException:在“MethodInvokingMessageProcessor”中处理消息时发生错误 [org.springframework.integration.handler.MethodInvokingMessageProcessor@c192373]; 嵌套异常是 java.lang.IllegalArgumentException:BeanFactory 不能是 null,failedMessage=GenericMessage
频道创建/注册示例如下:
deltaupdatedchannel = new DirectChannel(); deltaupdatedchannel.setBeanName("deltaupdatedcontroller");
serviceActivator = new ServiceActivatingHandler(deltaSummaryController, "updateDelta2");
handlerlist.add(serviceActivator);
beanFactory.registerSingleton("deltaupdatedcontroller", deltaupdatedchannel);
beanFactory.initializeBean(deltaupdatedchannel, "deltaupdatedcontroller");
deltaupdatedchannel.subscribe(serviceActivator);
通道用于进行以下调用:this.deltaupdatedcontrollerchannel.send(MessageBuilder.withPayload(summarydto).build());
频道调用以下代码:
public void updateDelta2(DeltaSummaryDTO dto) {
this.messagingTemplate.convertAndSend(
"/topic/updatedelta", dto);
}
这里的messagingTemplate是org.springframework.messaging.core.MessageSendingOperations。
我怎样才能让他们再次工作?
请与我们分享这样做的原因registerSingleton()
。 为什么仅仅简单的 bean 注册对你来说还不够?
要解决该问题,您还需要在registerSingleton()
之后调用initializeBean(Object existingBean, String beanName)
) 。
但是,不能保证这将是错误的终结。 我建议修改一个设计以支持普通的 bean 定义,而不是那个手动的定义......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.