弹簧集成服务 - 激活器错误

时间:2015-10-12 12:42:24

标签: spring-integration

我尝试在文件入站通道适配器和FileSplitter之间预处理文件。为此,我写了一个执行工作的类:\

@MessageEndpoint
public class ReleaseManagerForFlatFile {

    @ServiceActivator
    public Message<?> processFileCounter(Message<?> message) {
        Get the job Done !
        return message;
    }
}

我将它包含在我的spring集成配置文件中:          

<int-file:inbound-channel-adapter
    directory="D:\Donnees\Dev\workspace-luna\FileAggreg\In" id="fileIn"
    auto-startup="true" channel="channelFile" prevent-duplicates="true">
    <int:poller fixed-rate="60000" />
</int-file:inbound-channel-adapter>
<int:channel id="channelFile" />
<int:service-activator id="releaseManager" input-channel="channelFile" output-channel="channelFileIn" 
    ref="releaseManagerForFlatFile" />
<int:channel id="channelFileIn" />
<int-file:splitter id="splitter" input-channel="channelFileIn" output-channel="channelSplitter" />

但是,当我启动链时,我得到了这个例外:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'releaseManagerControl': Cannot resolve reference to bean 'org.springframework.integration.config.ServiceActivatorFactoryBean#1' while setting bean property 'handler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.config.ServiceActivatorFactoryBean#1': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Target object of type [class org.springframework.integration.endpoint.EventDrivenConsumer] has no eligible methods for handling Messages.
...
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.config.ServiceActivatorFactoryBean#1': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Target object of type [class org.springframework.integration.endpoint.EventDrivenConsumer] has no eligible methods for handling Messages.
Caused by: java.lang.IllegalArgumentException: Target object of type [class org.springframework.integration.endpoint.EventDrivenConsumer] has no eligible methods for handling Messages.

之前我写了许多服务激活器,我从未遇到过这个问题...... 上下文:Spring Integration 4.2

2 个答案:

答案 0 :(得分:0)

我刚刚使用您的确切代码进行测试,没有任何问题。

  

[class org.springframework.integration.endpoint.EventDrivenConsumer]类型的目标对象没有合格的方法来处理消息。

这意味着您的releaseManagerForFlatFile bean不是ReleaseManagerForFlatFile实例,而是上下文中的其他一些消费者端点。

也许您有一个重复的bean名称?

org.springframework启用DEBUG日志记录会有所帮助 - 您可以查看正在处理和连接在一起的bean定义。

答案 1 :(得分:0)

我想你需要像下面那样声明新的bean

<bean id="releaseManagerForFlatFile" class="package.name.ReleaseManagerForFlatFile"></bean>

我面临同样的问题,但这对我有用。希望这有帮助。