简体   繁体   中英

Spring integration errors after migration to spring 5

I have been using Spring integration (different types of channels) with Spring 4 for some time. After i tried to upgrade my environment to Spring 5, they stopped working with errors such as the following:

org.springframework.messaging.MessageHandlingException: error occurred during processing message in 'MethodInvokingMessageProcessor' [org.springframework.integration.handler.MethodInvokingMessageProcessor@c192373]; nested exception is java.lang.IllegalArgumentException: BeanFactory must not be null, failedMessage=GenericMessage

Sample channel creation/registration is as follows:

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);

Channels are used to make the following call: this.deltaupdatedcontrollerchannel.send(MessageBuilder.withPayload(summarydto).build());

And channel calls the following code:

public void updateDelta2(DeltaSummaryDTO dto) {

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

Here messagingTemplate is org.springframework.messaging.core.MessageSendingOperations.

How can i make them work again?

Share, please, with us the reason doing that registerSingleton() . Why just plain bean registration is not enough for you?

To fix that problem you need to call also initializeBean(Object existingBean, String beanName) after that registerSingleton() .

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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