Spring Integration - 在 Xpath-splitter 之后移动文件

标签 spring spring-integration splitter

我正在使用 spring 集成,我有下一个案例:我正在读取一个带有 int-file:inbound-channel-adapter 的 XML 文件,我用 拆分文件em>int-xml:xpath-splitter,问题是我需要在拆分后移动文件。

我想要 int-xml:xpath-splitter 的所有功能加上移动文件,我应该实现一个扩展 XPathMessageSplitter 的自定义拆分器吗?还是有任何其他方法可以使用开箱即用的组件来做到这一点?

谢谢。

<int-xml:xpath-splitter id="salesTransSplitter" 
                   input-channel="salesInputChannel"
                   output-channel="splitterOutChannel" order="1">
    <int-xml:xpath-expression expression="/sales_transactions/trans"/>      
</int-xml:xpath-splitter>   

最佳答案

像这样的东西应该有用...

<int-file:inbound ... channel="foo" />

<int:publish-subscribe-channel id="foo" />

<int-xml:xpath-splitter input-channel="foo" ... order="1" />

<int-service-activator input-channel="foo" order="2"
      expression="payload.renameTo(new java.io.File('/newDir/' + payload.name)" output-channel="nullChannel" />

如果您想测试重命名是否成功,请发送到 nullChannel 以外的其他 channel - bool 值 true 表示成功。

编辑

对此感到抱歉; order 应在每个消费端点上得到支持,我将打开一个 JIRA 问题。

order 不是绝对必要的;如果不存在 order,将使用它们在配置中出现的顺序;我只是想把它说清楚。

有(至少)两个解决方法:

  1. BOTH 消费者中删除 order 属性,他们将按照它们在 XML 中出现的顺序被调用。
  2. 将 XPath 拆分器配置为普通拆分器,它确实支持顺序...

    <int:splitter id="salesTransSplitter" order="1"
               input-channel="salesInputChannel"
               output-channel="splitterOutChannel" order="1">
        <bean class="org.springframework.integration.xml.splitter.XPathMessageSplitter">
            <constructor-arg value="/sales_transactions/trans" />
        </bean>
    </int-xml:xpath-splitter>   
    

关于Spring Integration - 在 Xpath-splitter 之后移动文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34074777/

相关文章:

java - Spring 社交 Facebook 个人资料仅提供 ID 和姓名

java - Bean 引用为空

java - 使用 CommandLineRunner spring boot 创建模式

java - Spring异常: org. springframework.expression.spel.SpelEvaluationException : EL1004E:(pos 8): Method call: Method retrieveRecords(java. util.Vector)

javascript - 做一个分离器很薄然后捕获它

Spring 属性占位符未在 jaxws :client (cxf) address property 中解析

spring - 通过 Spring 集成入站适配器接收 JMS 消息随机失败

unit-testing - 如何在Spring集成中进行单元测试?

notifications - NSSplitView 拆分器 Pane 更改通知

javascript - 拆分器不适用于 &lt;iframe&gt; 或 <object>