Apache Camel,Spring Boot 实现文件复制,转移 (转)
基本框架
Apache Camel
Spring Boot
Maven
开发过程
1.新建一个POM(quickstart)项目,在POM文件中添加Camel和Spring Boot的依赖
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>2.18.1</version>
</dependency>
</dependencies>
2.新建Application.java 启动类
@SpringBootApplication
public class Application{
public static void main(String[] args) {
final ApplicationContext context = new SpringApplication(Application.class).run(args);
final CamelSpringBootApplicationController controller = context.getBean(CamelSpringBootApplicationController.class);
controller.run();
}
}
3.新建RouteBuilder.java 消息路由
@Component
public class RouteBuilder extends SpringRouteBuilder { @Override
public void configure() throws Exception {
from("file:C:/Temp/inbox").to("file:C:/Temp/outbox");
}
}
4.启动Application的main函数,C:/Temp/inbox下的文件将会被自动拷贝到C:/Temp/outbox,camel会一直监控inbox文件夹,一旦有新文件出现,就会被立即拷贝到outbox。
5.更多高级应用的参数配置
- 处理完的文件移动到C:/Temp/inbox/.done 目录中,进行备份,不指定的话,会默认备份至C:/Temp/inbox/.camel
from("file:C:/Temp/inbox?move=.done").to("file:C:/Temp/outbox");
- 删除处理完成的文件
from("file:C:/Temp/inbox?delete=true").to("file:C:/Temp/outbox");
- 处理中的文件单独放在一个文件夹,文件第一步从inbox移动到inprogress,处理完成之后,再移动到.done
from("file:C:/Temp/inbox?preMove=inprogress&move=.done").to("file:C:/Temp/outbox");
- 按日期备份处理完的文件
from("file:C:/Temp/inbox?move=backup/${date:now:yyyyMMdd}/${file:name}").to("file:C:/Temp/outbox");
- 记录处理失败的文件
moveFailed=/error/${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.${file:ext}
转载至:https://www.jianshu.com/p/3e505db9cd63
Apache Camel,Spring Boot 实现文件复制,转移 (转)的更多相关文章
- Spring Boot入门——文件上传与下载
1.在pom.xml文件中添加依赖 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="ht ...
- 51. spring boot属性文件之多环境配置【从零开始学Spring Boot】
原本这个章节是要介绍<log4j多环境不同日志级别的控制的>但是没有这篇文章做基础的话,学习起来还是有点难度的,所以我们先一起了解下spring boot属性文件之多环境配置,当然文章中也 ...
- spring boot:单文件上传/多文件上传/表单中多个文件域上传(spring boot 2.3.2)
一,表单中有多个文件域时如何实现说明和文件的对应? 1,说明和文件对应 文件上传页面中,如果有多个文件域又有多个相对应的文件说明时, 文件和说明如何对应? 我们在表单中给对应的file变量和text变 ...
- Apache Camel继承Spring Boot 实现文件远程复制和转移
pom.xml <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-f ...
- Spring Boot属性文件配置文档(全部)
This sample file is meant as a guide only. Do not copy/paste the entire content into your applicatio ...
- AJAX跨域访问(从Tomcat8到Apache/Nginx/Spring Boot)
1.在Tomcat的Root目录下放入如下的文件 apache-tomcat-8.0.12X64\webapps\ROOT clientaccesspolicy.xml文件 <?xml vers ...
- Spring Boot 上传图片文件
步骤一:基于前面springboot入门小demo 基于的springboot入门小demo,已包含了前面文章的知识点(比如:热部署.全局异常处理器). 步骤二:创建uploadPage.jsp上传页 ...
- spring 及 spring boot 资源文件配置
Spring配置文件引入xml文件: <import resource=" " />标签使用总结 https://www.cnblogs.com/javahr/p/83 ...
- spring boot实现文件上传下载
spring boot 引入”约定大于配置“的概念,实现自动配置,节约了开发人员的开发成本,并且凭借其微服务架构的方式和较少的配置,一出来就占据大片开发人员的芳心.大部分的配置从开发人员可见变成了相对 ...
随机推荐
- Ionic cordova-plugin-splashscreen
1.添加插件 cordova plugin add https://github.com/apache/cordova-plugin-splashscreen.git 2.设置启动画面 在根目录下面r ...
- 软件-浏览器-GoogleChrome:Google Chrome
ylbtech-软件-浏览器-GoogleChrome:Google Chrome Google Chrome是一款由Google公司开发的网页浏览器,该浏览器基于其他开源软件撰写,包括WebKit, ...
- pycharm 安装与激活
---恢复内容开始--- 环境:Windows 专业版 1.下载安装 1.到官网下载专业版(专业版功能更全(但要激活码),社区版免费) 2.下载完后双击.exe 文件进行安装 NEXT 下一步 NEX ...
- Consul3-使用consul作为配置中心
在前面的文章中学习了consul在windows下的安装配置,然后consul作为spring boot的服务发现和注册中心,详细的参考: https://blog.csdn.net/j9038291 ...
- Mysql中ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8怎么转换为sql sever2008的代码
ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8转换sql server AUTO_INCREMENT=2 ,是 自动递增列的 初始数值 = 2, ...
- ubuntu 16.04 换源
第一步:备份原来的源文件 cd /etc/apt/ 命令 cp sources.list sources.list.bak 将sources.list备份到sources.list.bak 第二步:替 ...
- Leetcode131. Palindrome Partitioning分割回文串
给定一个字符串 s,将 s 分割成一些子串,使每个子串都是回文串. 返回 s 所有可能的分割方案. 示例: 输入: "aab" 输出: [ ["aa",&quo ...
- clientHeight、offsetHeight 区别 笔记
一张图 说明全部 clientHeight和clientWidth用于描述元素内尺寸,是指元素内容+内边距大小,不包括边框(低版本IE下实际包括).外边距.滚动条部分 offsetHeight和off ...
- laravel--设置不需要csrfToken校验的接口
一般是前后端分离或者支付宝响应的时候需要不设置csrfToken校验的接口,laravel推荐使用passport安全校验设计接口
- 移动web--移动屏幕适配-完整的viewport设置