CamelJmsToFileDemo 博客分类: Apache Camel Camel
程序员文章站
2024-02-22 14:17:10
...
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.NoTypeConversionAvailableException;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.file.GenericFile;
import org.apache.camel.component.file.GenericFileConverter;
import org.apache.camel.impl.DefaultCamelContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ssgx.calypso.processor.CompareProcessor;
public class CamelJmsToFileDemo {
public CamelJmsToFileDemo() {
}
private static int m = 0;
static Logger LOG = LoggerFactory.getLogger(CamelJmsToFileDemo.class);
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
public void configure() throws Exception {
//只处理.txt后缀结尾的文件
from("file://test1?include=.*\\.txt&delay=30000").to("file://test");
from("file://test2?include=.*\\.txt&delay=30000").to("file://test");
}
});
context.start();
context.addRoutes(new RouteBuilder() {
public void configure() throws Exception {
Thread.sleep(5000);
File file = new File("test");
System.out.println(" path=" + file.getAbsolutePath());
String[] strs = file.list();
InputStream is = new FileInputStream(new File("fileList/fileList.txt"));
BufferedReader reader = new BufferedReader(
new InputStreamReader(is));
String temp = null;
boolean all = true;//all file is ready
while ((temp = reader.readLine()) != null) {
System.out.println("neirong:" + temp);
for (int i = 0; i < strs.length; i++) {
System.out.println("strs[i]:" + strs[i]);
if (temp.equals(strs[i])) {
break;
}
if (temp != strs[i] && i == strs.length - 1) {
all = false;
}
}
}
System.out.println("all:" + all);
if (all) {
from("file://test").process(new CompareProcessor());
}
}
});
// context.addRoutes(new TimerRouteBuilder());
Thread.sleep(5000);
context.stop();
}
}
推荐阅读
-
processor 博客分类: Apache Camel camel
-
CamelJmsToFileDemo 博客分类: Apache Camel Camel
-
Camel 中的几个重要概念之 CamelContext与CamelTemplate 博客分类: Camel ExchangeSpring配置管理junit项目管理
-
Spring Integration component of Camel 博客分类: Camel SpringSVNActiveMQ编程Apache
-
Apache Way -- Meritocracy 博客分类: 开源 Apache活动工作
-
(estreat) Apache camel 博客分类: Camel apache camel
-
Apache ServiceMix入门之三 博客分类: ESB/SOAosgi osgisftpblueprintsshcamel
-
Camel Routes 博客分类: Apache Camel apache camelcamelRoutes
-
Apache Camel 2.0.0 正式发布了 博客分类: Camel ApacheExchangefreemarkerjsonJDK
-
ActiveMQ+Camel+Spring+jms Demo(一) 博客分类: activemq camel spring jms activemqcamelspringjms