简体   繁体   中英

Spring Integration gateway error channel - no such bean exception

I've configured a spring integration gateway with a service activator backed by a threadpool. Everything works fine, till I try to add my own error channel. Spring begins to complain that it cannot find a bean by the name of the error channel.

Here is my xml config:

    <int:gateway service-interface="Messaging.SendMessageToDeviceGateWay"
        error-channel="send_message_to_device_error_channel"
        default-request-channel="send_message_to_device_channel" 
        id="send_message_to_device_gateway">

        </int:gateway>

    <int:channel id="send_message_to_device_channel">
        <int:queue message-store="redisMessageStore" />
    </int:channel>

    <bean id="sendMessageToDeviceServiceBeanId" class="Messaging.SendMessageToDeviceService" />

    <int:service-activator input-channel="send_message_to_device_channel"
        ref="sendMessageToDeviceServiceBeanId" method="send_message">
        <int:poller fixed-rate="500" time-unit="MILLISECONDS"
            task-executor="send_message_to_device_task_executor" receive-timeout="0" />
    </int:service-activator>


    <bean id="sendMessageToDeviceErrorHandlerBeanId" 
        class="Messaging.SendMessageToDeviceErrorHandler" />



    <int:service-activator input-channel = "send_message_to_device_error_channel"
        ref="sendMessageToDeviceErrorHandlerBeanId" method="handle_error">
    </int:service-activator>

The error I am seeing is :

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'send_message_to_device_gateway': Cannot resolve reference to bean 'send_message_to_device_error_channel' while setting bean property 'errorChannel'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'send_message_to_device_error_channel' is defined
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1469)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1127)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1051)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:949)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533)
... 24 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'send_message_to_device_error_channel' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:694)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1168)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:281)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
... 37 more

Why is it looking for a bean by that name?

Thanks in advance, Richard.

That's correct: any bean must be presented in the application context.

Even if you use a default errorChannel , it is populated to the application context by the Spring Integration infrastructure.

So, you must provide <channel id="send_message_to_device_error_channel"/> anyway.

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