【问题标题】:Migrating from service-mix file poller to apache camel file poller从服务混合文件轮询器迁移到 apache 骆驼文件轮询器
【发布时间】:2020-08-25 17:37:00
【问题描述】:

我是 apache 骆驼的新手。我想从服务混合文件轮询器迁移到骆驼文件轮询器。我正在尝试这样做,但目前我没有什么要测试的,因为我必须对此进行编码并给某人进行测试。那么有人可以帮我检查一下我的方向是否正确吗?

Service-mix File Poller 代码:

    <sm:activationSpec componentName="abcFilePoller"
        destinationService="b:destinationA"
        service="b:abcFilePoller">
        <sm:component>
            <bean class="org.apache.servicemix.components.file.FilePoller">
                <property name="file" value="file://D:/input" />
                <property name="period" value="20000"/>
                <property name="archive" value="file://D:/archive" />
                <property name="filter" ref="abcFileFilter" />
                <property name="marshaler">
                    <bean class="org.apache.servicemix.components.util.BinaryFileMarshaler" />
                </property>
            </bean>
        </sm:component>
    </sm:activationSpec>
    <sm:activationSpec componentName="destinationA"
        service="b:destinationA">
        <sm:component>
            <bean
                class="com.abc.file.ABCReceiverComponent">
            </bean>
        </sm:component>
    </sm:activationSpec>
        <bean id="abcFileFilter" class="org.apache.commons.io.filefilter.WildcardFileFilter">
<constructor-arg value="A*.ID" />

Apache Camel 文件轮询器

    <camel:route id="abcFilePoller">
        <camel:from
            uri="timer://time?period=20000"/>
        <camel:pollEnrich uri="file://D:/input"/>
        <camel:filter ref="abcFileFilter"></camel:filter>
        <camel:to uri="file://D:/archive" />
        <camel:to uri="" />
    </camel:route>

<bean id="abcFileFilter" class="org.apache.commons.io.filefilter.WildcardFileFilter">
    <constructor-arg value="A*.ID" />                                                                                                                                                                                             
</bean>

我还没有完成骆驼编码。我已经离开了目的地部分。而且我不知道service-mix 部分中使用的marshaler。如何使用骆驼实现BinaryFileMarshaler

【问题讨论】:

    标签: java jakarta-ee apache-camel apache-servicemix


    【解决方案1】:

    您可以在 Apache Camel 中更轻松地做到这一点,您可以在文件端点中配置过滤,所以它就变成了

       <route>
         <from uri="file:D:/input?delay=20000&amp;include=A.*ID"/>
         <to uri="file:D:/archive"/>
      </route>
    

    请注意,include 选项使用正则表达式,因此,如果您不熟悉它,可能需要尝试一下才能使表达式按预期工作。但它的标准 java 正则表达式。

    查看更多信息:https://camel.apache.org/components/latest/file-component.html

    对于 Apache Camel 的新用户,请参阅:http://java.dzone.com/articles/open-source-integration-apache

    【讨论】:

    • 谢谢。通过看到您在那篇帖子stackoverflow.com/questions/9516843/… 中的回答,我刚刚实现了这一点。如果可能的话,你能帮我解决这个“BinaryFileMarshaler”吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-29
    相关资源
    最近更新 更多