2016-08-10 11 views
0
<spring.framework.version>4.3.0.RELEASE</spring.framework.version> 

xmlベースの統合構成を@Configurationクラスに変換したいとします。具体的にインバウンド・チャネル・アダプターの@Bean構成

<int:channel id="files"/> 
<int-file:inbound-channel-adapter id="filesIn" 
            channel="files" 
            directory="file:${local.send.dir}" 
            filename-pattern="*.txt" 
            prevent-duplicates="true"> 
    <int:poller fixed-rate="${poll.millis}" max-messages-per-poll="1"/> 
</int-file:inbound-channel-adapter> 

<int:service-activator input-channel="files" 
         ref="fileActivator"/> 

を変換する方法これは私がこれまで持っているものです:正しいですが、SIインフラストラクチャの作成を知らせるために、あなたの@Configurationクラスの少なくとも一方に@EnableIntegrationが必要

@Bean 
public DirectChannel files() { 
    DirectChannel chnl = new DirectChannel(); 

    return chnl; 
} 

@Bean 
@InboundChannelAdapter(channel = "files") 
public MessageSource<File> filesIn() { 
    FileReadingMessageSource source = new FileReadingMessageSource(); 
    source.setDirectory(new File(env.getProperty("local.send.dir"))); 
    source.setFilter(new SimplePatternFileListFilter("*.txt")); 

    return source; 
} 

答えて

0

fileActivatorがPOJOの場合は、@ServiceActivatorと注釈を付けて@Beanとしてください。

MessageHandlerの場合は、@ServiceActivator@Beanの定義に追加します。

関連する問題