Announcement Announcement Module
Collapse
No announcement yet.
sftp:inbound-channel-adapter and delete-remote-files Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • sftp:inbound-channel-adapter and delete-remote-files

    Hi everyone,

    I apologise in advance if there's been already a discussion on this matter. As I've yet to find it, please redirect me there and close/remove this thread.

    Scenario: batch app that monitors remote folder via sftp, transfers files and processes them

    Problem: using a property to define whether my "sftp:inbound-channel-adapter" should "delete-remote-files". Using the snippet below I encountered the following error:
    Offending resource: class path resource [launch-context.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefin itionStoreException: Line 14 in XML document from class path resource [META-INF/spring/si-module-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-datatype-valid.1.2.1: '${delete-remote-files}' is not a valid value for 'boolean'.

    Context snippet:
    Code:
        <sftp:inbound-channel-adapter id="sftpInboundAdapter" channel="inputDirChannel"
                 session-factory="sftpSessionFactory" local-directory="file:${local.dir}" remote-directory="${remote.dir}"
                 filename-pattern="${filename-pattern}" temporary-file-suffix="INC" auto-startup="${sftp.enabled}"
                 delete-remote-files="${delete-remote-files}" >
            <int:poller ref="poller" />
        </sftp:inbound-channel-adapter>

    Any help in overcoming this issue is greatly appreciated.

    P.S. latest idea that came to mind as a workaround is to define a different channel adapter for both true/false, each in its own xml, and then include the right one based on the value of the property, but I'd prefer a more elegant solution.

    Kind regards,
    M

  • #2
    I just looked. Its a bug in XSD
    Code:
    <xsd:attribute name="delete-remote-files" type="xsd:boolean">
    Since its boolean it does not except placeholders.
    Could you please file JIRA Bug for this?

    Comment


    • #3
      Hi Oleg,

      I noticed the xsd definition myself but I thought it was meant to be like that... thanks for the info, I've opened https://jira.springsource.org/browse/INT-1965, although it might some editing (I believe it has something to do with me not escaping the braces in ${delete-remote-files})

      In the meantime if anyone else has a similar problem, my workaround is:
      1) create an xml file with a channel definition having delete-remote-files="true" and one having "false"

      2) in the main context xml reference
      Code:
      <import resource="classpath:/META-INF/spring/file-remove-${delete-remote-files}-sftp-channel.xml" />
      3) since spring will try to include the resource first and later in the process set the placeholders, you need to manually read the property ${delete-remote-files} and add it to the system, prior to instantiating the spring context

      Cheers

      Comment


      • #4
        Thanks

        It will be addressed shortly an we are planning a release of 2.0.5 some time next week, so the wait will not be long, but it will be in the tonight's nighty

        Comment

        Working...
        X