我是 Spring 集成的新手。我有以下要求。
- 轮询文件夹(文件系统)
- 获取 XML 文件
- 针对 XSD 进行验证
- 如果无效,请将其移至其他文件夹。
- 如果有效,则调用服务激活器,该激活器会将 xml 文件作为输入发送到 Rest ful Web 服务。
我有以下代码:
<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=""/>
这里我坚持以上 4 点和 5 点。请帮助我如何实现它?
谢谢!
最佳答案
步骤 4+5 正是验证过滤器的丢弃 channel 和输出 channel 的用途。只需将出站 channel 适配器与丢弃 channel 连接即可将无效文档写入文件夹。将您的服务激活器连接到输出 channel 。
关于java - spring集成模式 validator 的使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13723687/