usage of spring integration's schema validator

2019-06-03 10:05发布

I am new to spring integration. i have below requirement.

  1. poll the folder(file system)
  2. get the XML file
  3. validate against XSD
  4. if it is invalid move it to different folder.
  5. if it is valid then invoke service activator which will send the xml file as an input to rest ful web service.

I have below code:

<int-file:inbound-channel-adapter auto-create-directory="true" channel="contentChannel"  id="inBoundChannelAdapter" directory="${someFolder}" prevent-duplicates="true">
            <int:poller max-messages-per-poll="1" fixed-rate="10000"/>

        </int-file:inbound-channel-adapter>

        <int:channel id="contentChannel"/>

        <int-xml:validating-filter id="schemaValidator" output-channel="someOutPutChannel" throw-exception-on-rejection="false" schema-location="${schema.location}" input-channel="contentChannel" discard-channel=""/>

Here i am stuck with above 4 and 5 points. Please help me how can i achieve it?

Thanks!

1条回答
Fickle 薄情
2楼-- · 2019-06-03 10:43

Step 4+5 is exactly what the discard-channel and output-channel of the validating-filter is for. Just connect an outbound-channel-adapter with the discard-channel to have invalid documents written to a folder. Connect your service activator to output-channel.

查看更多
登录 后发表回答