Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 26

Thread: file:outbound-channel-adapter : file extension ".writing" issue

  1. #11
    Join Date
    Aug 2009
    Location
    Paris, France
    Posts
    32

    Default

    Thank you very much for you quick response, i tough there were a new parameter to set, but if say it is totally transparent, it's ok for me.
    Sorry not to have tested carefully before, i was expecting some overwrite file parameter.
    Thanks

  2. #12
    Join Date
    Aug 2009
    Location
    Paris, France
    Posts
    32

    Default

    well it doesn't seem to work for me:
    springintegration.png

    after writing file with the same name, i still have two files (one with .writing extension, and the old one)
    I have no error in log file.
    Can you help ?

    thanks

  3. #13
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Can you describe your environment and share your config so we can try to reproduce it?

  4. #14
    Join Date
    Aug 2009
    Location
    Paris, France
    Posts
    32

    Default

    Sure:

    - windows 7 Pro SP1
    - all spring integration components updated to 2.0.5

    I am using a home made component which is inheriting from an AbstractPollingEndpoint implementing MessageHandler DisposableBean and MessageSource<File>, which have been working with no particular problem for a few years.

    Here is how i initialize the writer part:

    if (outputDirectory != null) {
    relativePath = conf.getString(getName() + ".output.relative.path","");
    filenamePattern = conf.getString(getName() + ".output.filename.pattern","");

    ouputFile = new File(outputDirectory + "/" + Utils.now(relativePath));
    if (!ouputFile.exists()) {
    logger.debug("Creating directory " + ouputFile);
    (new File(ouputFile.getPath())).mkdirs();
    } else if (!ouputFile.canWrite()) {
    logger.debug("Trying to set directory readable " + ouputFile);
    (new File(ouputFile.getPath())).setWritable(true);
    }
    writer = new FileWritingMessageHandler(ouputFile.getAbsoluteFil e());
    writer.setAutoCreateDirectory(true);

    writer.setChannelResolver(ApplicationContextProvid er.getChannelRegistry());
    writer.setBeanFactory(ApplicationContextProvider.g etApplicationContext());
    writer.setRequiresReply(false);

    String channel = BeansNormalizedNames.getCoreRouterInputChannel();
    writer.setOutputChannel((MessageChannel) ApplicationContextProvider.getChannelRegistry().ge tChannel(channel));
    writer.afterPropertiesSet();

    logger.info("writing in " + ouputFile.getAbsolutePath());
    }
    And the corresponding configuration file:

    USER_PLATE_XML_FILE_WRITER.type = FILE
    USER_PLATE_XML_FILE_WRITER.trigger = 10000
    USER_PLATE_XML_FILE_WRITER.messages.per.poll = 10
    USER_PLATE_XML_FILE_WRITER.output.directory = C:/Users/max/Documents/AndromasTest/plates
    USER_PLATE_XML_FILE_WRITER.output.relative.path = yyyy/MM/dd
    Just tell me if this is not clear...

  5. #15
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Why are you not using <int-file:outbound-channel-adapter>? I mean why do you need custom component?

  6. #16
    Join Date
    Aug 2009
    Location
    Paris, France
    Posts
    32

    Default

    Because they can be dynamiccally instanciated at runtime.

  7. #17
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Ok, since you are creating it yourself, would you be able to compile a test case that reproduces this issue and attach it to this forum and I'll take a look?

  8. #18
    Join Date
    Aug 2009
    Location
    Paris, France
    Posts
    32

    Default

    oh, it seems the .writing file is overwritten correctly, but not the original !

  9. #19
    Join Date
    Aug 2009
    Location
    Paris, France
    Posts
    32

    Default

    so, to sum up :

    first time file created correctly with filename
    second time, second file created called : filename.writing
    then after : file filename.writing overwritten but original file never changes

    thanks

  10. #20
    Join Date
    Aug 2009
    Location
    Paris, France
    Posts
    32

    Default

    Hi Oleg,

    Please find an example of what i've described just in previous post.
    Here is my spring integration XML file (at least the file writing part) :

    Code:
    <bean id="toStringTransformer" class="org.springframework.integration.xml.transformer.ResultToStringTransformer" />
      	<integration:channel id="toDiskChannel"></integration:channel>
      	<integration:channel id="testOutputChannel"></integration:channel>
      	
      	<si-xml:marshalling-transformer marshaller="testResultMessageMarshaller" 
      		output-channel="toDiskChannel" 
      		input-channel="testOutputChannel" 
      		result-transformer="toStringTransformer" />
      		
      	<file:outbound-channel-adapter channel="toDiskChannel" 
      		directory="${test.output.directory}">
      	</file:outbound-channel-adapter>
    Then in my code, when i send messages to this channel:

    Code:
    Message<GenericXMLMessageType> mess = MessageBuilder.withPayload(msg.getPayload()).
    			copyHeaders(fileContents.getHeaders()).
    			build();
    			
    			MessageChannel channel2 = (MessageChannel)ApplicationContextProvider.getApplicationContext().getBean("testOutputChannel");
    			channel2.send(mess);
    The first is written correctly, and the following message with identical filename produce a .writing file, which is correctly overwritten then (with following messages) :

    overwriteBug.png


    Thank you very much

    Max

Posting Permissions

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