Announcement Announcement Module
Collapse
No announcement yet.
cannot slurp a file via file adapters Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • cannot slurp a file via file adapters

    Hello all
    i am trying to read teh content from a file in directory X.
    the setup is simple:
    - have an inbound file adapter which read the file and post the message to a channel
    - have a transformer that transform teh file into a String
    - have an output adapter that will read teh string and output to console

    here's my setup
    Code:
    <integration:chain input-channel="fileReadChannel">
    		<integration:transformer id="stringTransformer" ref="objectToStringTransformer" />
    		<integration:service-activator ref="fileSucker" method="suckAFile"/>
    	</integration:chain>
    
    <file:inbound-channel-adapter id="filesIn" channel="fileReadChannel"
    		directory="file:/c:/SpringInteg/sourceFiles">
    		<integration:poller id="defaultPoller" default="true" max-messages-per-poll="5">
         		<integration:interval-trigger interval="3" time-unit="SECONDS"/>
     		</integration:poller>
    	</file:inbound-channel-adapter>	
    
    <bean id="objectToStringTransformer" class="org.springframework.integration.transformer.ObjectToStringTransformer"/>
    
    	<bean id="fileSucker" class="com.sample.handlers.FileSucker"/>
    Somehow, when ir un my application and output the content of the file in fileSucker, i get
    following message
    Code:
    2009-12-31 13:00:56,863 [handlers.FileSucker                     ] INFO - ReceivedFileContents
    c:\SpringInteg\sourceFiles\TODO.txt
    here's code of my FileSucker (copied from the net in one of spring integ examples)
    Code:
    package com.sample.handlers;
    
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    
    public class FileSucker {
    	   private static final Log LOGGER = LogFactory.getLog(FileSucker.class);
    
    	   public void suckAFile(String fileContents) {
    	      LOGGER.info("ReceivedFileContents\n" + fileContents);
    	   }
    	}
    anyone could help?

    regards
    marco

  • #2
    sorted.
    i was just using the wrong transformer.

    i used
    Code:
    <bean id="objectToStringTransformer" class="org.springframework.integration.transformer.ObjectToStringTransformer
    instead of
    Code:
    <bean id="objectToStringTransformer" class="org.springframework.integration.file.transformer.FileToStringTransformer"/>
    regards
    marco

    Comment


    • #3
      By the way, there is namespace support for both of those transformers.

      Comment


      • #4
        Mark
        thanks... i was unable to find those two transformers here

        http://www.springframework.org/schem...ration-1.0.xsd

        am i looking at an outdated version of schema?

        rgards
        marco

        Comment


        • #5
          Yes, there is a 2.0 version. You can even leave the version out of your schemaLocations now, Spring will take care of it for you.

          Comment

          Working...
          X