本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长


+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

从 service-mix 文件轮询器迁移到 apache camel 文件轮询器

发布于2023-03-30 19:01     阅读(376)     评论(0)     点赞(19)     收藏(3)


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

服务混合文件轮询器代码:

    <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>

I have not completed the camel coding. I have left with destination part. And I have no idea about the marshaler that is used in the service-mix part. How to implement that BinaryFileMarshaler using camel.


解决方案


你可以在 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



所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:http://www.javaheidong.com/blog/article/666433/9af0e70b823093c8850b/

来源:java黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

19 0
收藏该文
已收藏

评论内容:(最多支持255个字符)