Skip to content

Commit 21db297

Browse files
committed
Change config path and created a sample test file.
1 parent ec38d43 commit 21db297

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package com.camelsample.filecomponent;
22

3+
import org.apache.camel.Exchange;
4+
import org.apache.camel.Message;
5+
import org.apache.camel.Processor;
36
import org.apache.camel.builder.RouteBuilder;
47

5-
public class CamelFileRouter extends RouteBuilder{
8+
public class CamelFileRouter extends RouteBuilder {
69
String srourePath;
710
String destinationPath;
811

@@ -13,7 +16,19 @@ public CamelFileRouter(String srourePath, String destinationPath) {
1316

1417
@Override
1518
public void configure() throws Exception {
16-
from("file:"+srourePath)
17-
.to("file:"+destinationPath);
19+
from("file:" + srourePath).process(new Processor() {
20+
@Override
21+
public void process(Exchange exchange) throws Exception {
22+
Message in = exchange.getIn();
23+
String data = in.getBody(String.class);
24+
/*
25+
* if message in a file contains hello, then change the body to
26+
* hello world
27+
*/
28+
if (data.contains("hello")) {
29+
in.setBody("hello world");
30+
}
31+
}
32+
}).to("file:" + destinationPath);
1833
}
1934
}
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
srcpath=/test/data1
2-
destinationpath=/test/data2
1+
srcpath=test/data1
2+
destinationpath=test/data2

Diff for: camel-example-filecomponent/test/data1/test.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello world

0 commit comments

Comments
 (0)