Announcement Announcement Module
Collapse
No announcement yet.
Spring filewatcher in clustered environment Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring filewatcher in clustered environment

    Hi,

    I am trying to implement a recursive filewatcher service using spring integration. I have implemented the org.springframework.integration.file.RecursiveLeaf OnlyDirectoryScanner class and the system is working fine ina single node. The problstarts when this code is deployed ina clusted environment.
    The folder that I am watching gets polled inparallel by both the instances and as a result I am receiving duplicate events.
    I have tried implementing the NIO locker based handling, but that is resulting in a locking issue.

    An alternative solution is to implement this as a quartz job and do away with the inbuilt filewatcher componenet, but I really dont want to do that.

    My configuration XMl file:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:integration="http://www.springframework.org/schema/integration"
    	xmlns:file="http://www.springframework.org/schema/integration/file"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/integration/file
    http://www.springframework.org/schema/integration/file/spring-integration-file-2.2.xsd 
    http://www.springframework.org/schema/integration
    http://www.springframework.org/schema/integration/spring-integration-2.2.xsd">
    
    	<bean
    		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
    	
    	<bean id="locker" class="org.springframework.integration.file.locking.NioFileLocker" />
    
    	<bean id="handler"
    		class="com.test.service.components.filewatcher.FileWatcherHandler" />
    		
    	<bean id="writer"
    		class="com.test.service.components.filewatcher.FileMoveHandler" />
    	<bean id="notifyActiviti"
    		class="com.test.service.components.filewatcher.FileWatcherServiceImpl" >
    	</bean>
    
    	<bean id="myscanner"
    		class="org.springframework.integration.file.RecursiveLeafOnlyDirectoryScanner" >
    		<property name="locker" ref="locker" />
    	</bean>
    
    	<file:inbound-channel-adapter id="filesIn" 
    		directory="file:/app/data/tempFiles" scanner="myscanner" prevent-duplicates="false">
    		<integration:poller id="poller" fixed-delay="3000" />
    <!--		<file:nio-locker />-->
    	</file:inbound-channel-adapter>
    
    
    	<integration:service-activator
    		input-channel="filesIn" output-channel="filesRouter" ref="handler" />
    
    	<integration:publish-subscribe-channel
    		id="filesRouter" />
    	<file:outbound-channel-adapter id="filesOut"
    		channel="filesRouter" directory="file:/users/home/test/tempWritable/"
    		delete-source-files="true" filename-generator="writer" order="1" />
    
    
    	<integration:service-activator
    		input-channel="filesRouter" ref="notifyActiviti" order="2" />
    		
    	<bean id="fileWatcherInit" 
    		class="com.test.service.components.filewatcher.FileWatcherInitializer" />
    
    </beans>
    Kind of stuck in a quandry, any help would be appreciated..


    Thanks
    Anirban

  • #2
    Hi, Anirban!
    Maybe Hazelcast will be usefull for you?
    http://forum.springsource.org/showth...237#post443237

    Take care,
    Artem

    Comment


    • #3
      Thanks, Cleric for the response. But unfortunately the in-memory solution is not something that I can leverage due to security constraints.

      Thanks
      Anirban

      Originally posted by Cleric View Post
      Hi, Anirban!
      Maybe Hazelcast will be usefull for you?
      http://forum.springsource.org/showth...237#post443237

      Take care,
      Artem

      Comment

      Working...
      X