Results 1 to 3 of 3

Thread: Adding file locking to SourcePollingChannelAdapter

  1. #1
    Join Date
    Nov 2011
    Location
    Charlotte, NC, USA
    Posts
    21

    Default Adding file locking to SourcePollingChannelAdapter

    I created a custom MessageSource to craft up a Message. The Message payload contains 2 files from a network drive (a data file and a control file).

    I am using a SourcePollingChannelAdapter with has my custom MessageSource injected as a source. All is working well at the moment.

    One thing I noticed is that I can inject a self defined taskExecutor into my SourcePollingChannelAdapter.

    My question is - is there any way I can inject some file locking (like nio-locker)?

    Here's my bean config:

    <bean id="tradeFeedMessageSource" class="com.cjansen.tradeFeedIntegrator.file.TradeF eedFileReadingMessageSource">
    <property name="directory" value="${rawSourceFile.directory}"/>
    <property name="filter" ref= "compositeControlFileFilter"/>
    <property name="scanEachPoll" value="true"/>
    <property name="controlFileExtension" value=".cntl"/>
    </bean>

    <task:executor id="rawDataFileExecutor" pool-size="10"/>

    <bean id="tradeFeedFileAdapter" class="org.springframework.integration.endpoint.So urcePollingChannelAdapter" >
    <property name="outputChannel" ref="rawDataFileChannel"/>
    <property name="source" ref="tradeFeedMessageSource"/>
    <property name="maxMessagesPerPoll" value="1"/>
    <property name="taskExecutor" ref="rawDataFileExecutor"/>
    </bean>

  2. #2
    Join Date
    Oct 2011
    Location
    Mumbai, India
    Posts
    213

    Default

    If at all you need to inject a file locker implementation that needs to be injected in your message source and not in the SourcePollingChannelAdapter

    For example, the FileReadingMessageSource is an implementation of MessageSource. It has a provision to inject a FileLocker (A spring integration interface to abstract the underlying locking mechanism to enable you provide your custom locking implementation). You need to have something similar i guess.
    Does that answer your question?

  3. #3
    Join Date
    Nov 2011
    Location
    Charlotte, NC, USA
    Posts
    21

    Default

    YES! Thats __exactly__ what I was looking for. Thank you Amol!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •