These days I have create my first route of apache camel for a real enterprise bizz.
Just as what 《Camel in Action》 says: "Camel is an integration framework that aims to make your integration projects productive and fun" , It`s awsome that the Java DSL looks so directly and the Spring DSL is so powerful that you can just config the Spring xml to route for your own without java compiling.
The route as follows:
<route id="lz" autoStartup="false" trace="true">
<from uri="ftp://lori@127.0.0.1:21?password=123&filter=#lzFtpFileNameFilter&maximumReconnectAttempts=1&reconnectDelay=3000&disconnect=true&pollStrategy=#lzPollingConsumerPollStrategy&throwExceptionOnConnectFailed=true"/>
<camel:onCompletion>
<process ref="stopLZRouteProcessor"/>
</camel:onCompletion>
<camel:log loggingLevel="INFO" message="Picked up ${file:name}"/>
<process ref="zipFileSplittingProcessor"/>
<split>
<simple>${body}</simple>
<unmarshal><csv /></unmarshal>
<bean ref="lzServiceBean" method="csv2MapList"/>
<split>
<simple>${body}</simple>
<camel:setHeader headerName="Subject"><camel:constant>Test subject</camel:constant></camel:setHeader>
<camel:setHeader headerName="From"><camel:constant>Lori</camel:constant></camel:setHeader>
<camel:setHeader headerName="contentType"><camel:constant>text/html;charset=UTF-8</camel:constant></camel:setHeader>
<camel:setHeader headerName="to"><camel:simple>${body[dest]}</camel:simple></camel:setHeader>
<to uri="velocity://template/test.vm?contentCache=true&encoding=utf-8"/>
<to uri="smtp://mail.elitecrm.com?username=loriling@elitecrm.com&password=0308"/>
</split>
</split>
</route>
With this route, the bigest problem is that I want to catch errors in the FTP endpoint (invalid login, server down, etc). I have tried errorHandler() but it only catches the errors produced after the message enters the exchange i.e. after from().
i try to set the FTP endpoint properties:
throwExceptionOnConnectFailed=true and pollStrategy=#lzPollingConsumerPollStrategy
then the FTPConsumer will thrown an exception if a successful connection and login could not be establish and using the custom PollingConsumerPollStrategy which coded:
consumer.stop();
in the rollback method.
Then the problem solved, it will only consume once if there is an exception of which FTP endpoint throws.
There are many features and EIPs that I havenot deal with and much more things i need to learn.
Last i extend my heartfelt gratitude to each camel authors and committers for bringing us so pretty project. Thanks again.
分享到:
相关推荐
ApacheCamel-JDBC Apache Camel JDBC组件 代码样例Demo
Apache Camel 开发使用指南中文版
ApacheCamel-FTP ApacheCamel-FTP Apache Camel FTP组件 Demo 样例
该文档来自阿帕奇2015中国路演。姜宁发表了题为“我和Apache Camel这些年/Years of Apache Camel and I”的主题演讲,欢迎下载!
简化软件集成:一个ApacheCamel教程在本教程中,您将了解集成大型软件的一些最大挑战,以及ApacheCamel如何轻松解决这些难题。在您的软件工程中,您可能至少做了一次以下操作:1.确定应启动数据发送的业务逻辑片段。...
01-ApacheCamel-HelloWorld Apache Camel Http helloworld Demo
05-ApacheCamel-CXF-WebService Apache Camel 集成 CXF组件,包含服务端、测试客户端
camel-idea-plugin, Apache camel IntelliJ IDEA 插件 Apache camel IDEA插件 IntelliJ IDEA的插件,为代码编辑器提供一组 Apache camel 相关的功能。插件包括:Java,XML,属性或者yaml文件中驼峰终结点的代码完成...
An advanced guide to Enterprise Integration using Apache Camel About This Book Integrate your applications with Apache Camel and enhance efficiency and scalability Master all the EIPs supported by ...
骆驼开发指南,企业集成,路由表达式和判断,camel高级编程,api组件框架,耗时半年翻译成果,全部为markdown文档!!!
camel direct http jdbc mybatis 等等组件 骆驼 camel部分源码分析
Apache Camel - CXF组件(Code First and WSDL File First) Apache Camel - JMS/ActiveMQ组件 Apache Camel - Jetty组件 Apache Camel - Timer组件 Apache Camel - JDBC组件 Apache Camel - Dynamic Control Route...
apache camel for windows
Apache Camel 框架实现的JMS路由。有图解,很详细。
ApacheCamel-JMS-ActiveMQ Apache Camel JMS ActiveMQ 使用样例 1.从本地读取信息推送到MQ中 2.从MQ中读取信息保存到本地
09-ApacheCamel-Timer Apache Camel Timer组件 定时器 代码Demo
此文档主要针对以下四个问题进行详细分析以及解答。 第一:我们要解决的企业应用集成问题。 第二:为什么使用Camel; 第三:Camel可以做什么? 第四:Camel的核心要素。