简体   繁体   English

Spring 迁移到 spring 后出现集成错误 5

[英]Spring integration errors after migration to spring 5

I have been using Spring integration (different types of channels) with Spring 4 for some time.我一直在使用 Spring 集成(不同类型的频道)与 Spring 4 一段时间。 After i tried to upgrade my environment to Spring 5, they stopped working with errors such as the following:在我尝试将我的环境升级到 Spring 5 后,他们停止工作并出现如下错误:

org.springframework.messaging.MessageHandlingException: error occurred during processing message in 'MethodInvokingMessageProcessor' [org.springframework.integration.handler.MethodInvokingMessageProcessor@c192373]; org.springframework.messaging.MessageHandlingException:在“MethodInvokingMessageProcessor”中处理消息时发生错误 [org.springframework.integration.handler.MethodInvokingMessageProcessor@c192373]; nested exception is java.lang.IllegalArgumentException: BeanFactory must not be null, failedMessage=GenericMessage嵌套异常是 java.lang.IllegalArgumentException:BeanFactory 不能是 null,failedMessage=GenericMessage

Sample channel creation/registration is as follows:频道创建/注册示例如下:

deltaupdatedchannel = new DirectChannel(); deltaupdatedchannel = new DirectChannel(); deltaupdatedchannel.setBeanName("deltaupdatedcontroller"); deltaupdatedchannel.setBeanName("deltaupdatedcontroller");

    serviceActivator = new ServiceActivatingHandler(deltaSummaryController, "updateDelta2");
    handlerlist.add(serviceActivator);
    
    
    
    beanFactory.registerSingleton("deltaupdatedcontroller", deltaupdatedchannel);
    beanFactory.initializeBean(deltaupdatedchannel, "deltaupdatedcontroller");
    deltaupdatedchannel.subscribe(serviceActivator);

Channels are used to make the following call: this.deltaupdatedcontrollerchannel.send(MessageBuilder.withPayload(summarydto).build());通道用于进行以下调用:this.deltaupdatedcontrollerchannel.send(MessageBuilder.withPayload(summarydto).build());

And channel calls the following code:频道调用以下代码:

public void updateDelta2(DeltaSummaryDTO dto) { public void updateDelta2(DeltaSummaryDTO dto) {

    this.messagingTemplate.convertAndSend(
            "/topic/updatedelta", dto);
}

Here messagingTemplate is org.springframework.messaging.core.MessageSendingOperations.这里的messagingTemplate是org.springframework.messaging.core.MessageSendingOperations。

How can i make them work again?我怎样才能让他们再次工作?

Share, please, with us the reason doing that registerSingleton() .请与我们分享这样做的原因registerSingleton() Why just plain bean registration is not enough for you?为什么仅仅简单的 bean 注册对你来说还不够?

To fix that problem you need to call also initializeBean(Object existingBean, String beanName) after that registerSingleton() .要解决该问题,您还需要在registerSingleton()之后调用initializeBean(Object existingBean, String beanName) ) 。

However there is no guarantee that this will be the end of errors.但是,不能保证这将是错误的终结。 I would suggest to revise a design in favor of normal bean definitions, not that manual one...我建议修改一个设计以支持普通的 bean 定义,而不是那个手动的定义......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM