简体   繁体   English

Apache骆驼从ftp到数据库

[英]Apache camel from ftp to database

Is it possible to solve following scenario with apache camel: 是否可以使用Apache骆驼解决以下情况:

Read from ftp (periodically) retrieve a zip file which contains xml, store this xml in database. 从ftp中读取(定期)检索包含xml的zip文件,并将此xml存储在数据库中。

The main question is which features exists in camel and which functionality and need to write on my own? 主要问题是骆驼中存在哪些功能,哪些功能需要我自己编写?

Yes, your route could look something like this (off the top of my head): 是的,您的路线可能看起来像这样(不在我的头上):

JaxbDataFormat jaxb = new JaxbDataFormat("com.example.foobar");

from("ftp://user:pass@server:21/inbox")
    .unmarshal().zip()
    .split(xpath("//foo"))
    .unmarshal(jaxb)
    .to("jpa:com.example.foobar.Foo")

This will poll a FTP server, unzip files, split the content in XML fragments, transform these to JPA entities and finally persist these objects in a database. 这将轮询FTP服务器,解压缩文件,将内容拆分为XML片段,将其转换为JPA实体,最后将这些对象保留在数据库中。 There are many variations possible, depending on your use case you can omit the splitter EIP or for example choose another persistence mechanism (MyBatis, Spring-JDBC, etc). 可能有多种变化,根据您的用例,您可以省略拆分器EIP或例如选择其他持久性机制(MyBatis,Spring-JDBC等)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM