choice
choice + when + otherwise şeklinde kullanılır
Örnek
Şöyle yaparız
from("file:src/data?noop=true").choice().when(xpath("/person/city = 'London'")).log("UK message").to("file:target/messages/uk").otherwise().log("Other message").to("file:target/messages/others");
Kullanım Örnekleri
Örnek - Dosya Kopyalamak
Şöyle yaparız
Örnek - Dosya Taşır
Şöyle yaparız.
Şöyle yaparız
İsim filtresi içindir
Örnek
Elimizde şöyle bir kod olsun
Örnek
Şöyle yaparız
Şöyle yaparız.
public class SimpleRouteBuilder extends RouteBuilder {
public static final String SOURCE_FOLDER = "/home/vikas/dev/camel/01/source";
public static final String SOURCE_FOLDER = "/home/vikas/dev/camel/01/target";
@Override
public void configure() throws Exception {
from("file:" + SOURCE_FOLDER).to("file:" + TARGET_FOLDER);
}
}
Örnek
Şöyle yaparız
import org.apache.camel.builder.RouteBuilder;import org.springframework.stereotype.Component;@Componentpublic class ActiveMQSenderRoute extends RouteBuilder {@Overridepublic void configure() throws Exception {from("file:files/input").to("activemq:myqueue");}}
charSet Alanı
Örnek
Şöyle yaparız
FilePoller olarak kullanmak içindir.
Örnek
Şöyle yaparız
Açıklaması şöyle
Açıklaması şöyle.Örnek
Şöyle yaparız
from("file://target/input?charset=UTF-8")
.process(new Processor() {
public void process(Exchange msg) {
String text = msg.getIn().getBody(String.class);
LOG.info("Processing text: " + text);
}
});
delay AlanıFilePoller olarak kullanmak içindir.
Örnek
Şöyle yaparız
from("file://target/input?delay=1000")
.process(new Processor() {
public void process(Exchange msg) {
File file = msg.getIn().getBody(File.class);
LOG.info("Processing file: " + file);
}
});
Açıklaması şöyleBy default, the file component will create a org.apache.camel.component.file.GenericFile object for each file found and pass it down your Route as message body. You may retrieve all your file information through this object. Alternatively, you may also use the Exchange API to auto convert the message body object to a type you expect to receive (eg: as with msg.getIn().getBody(File.class)). In the example above, the File is a type you expect to get from the message body, and Camel will try to convert it for you. Camel uses the context’s registry space to pre-register many TypeConverter's that can handle the conversion of most of the common data types (like Java primitives). These TypeConverters are a powerful way to make your Route and Processor more flexible and portable.delete Alanı
Açıklaması şöyle
There many configurable options from the file component. .... Some of these default behaviors are such that if the input folder doesn’t exist, it will create it. And when the file is done processing by the Route, it will be moved into a .camel folder. If you don’t want the file at all after processing, then set delete=true in the URL.fileName Alanı
The file producer will by default "override" if a file already exists.Açıklaması şöyle.
The fileName option supports the simple and file languageÖrnek - Dosya Taşır
...
That means the file name can be dynamic computed...
Şöyle yaparız
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
from("file://./?fileName=in.csv&noop=true")
.to("file://./?fileName=out.csv")
.end();
}
});
Açıklaması şöyle....which will take the contents of the in.csv file from the current directory and copy all the contents for the out.csv file in the same directory. The noop=true parameter tells Camel not to do anything with the file. Without this option Camel would move the the file into .camel directory after processing it.filter Alanı
İsim filtresi içindir
Örnek
Elimizde şöyle bir kod olsun
@Component
public class TestFileFilter implements GenericFileFilter {
@Override
public boolean accept(GenericFile file) {
if (file.getFileName().matches("^[test_files]"))
return true;
return false;
}
}
Şöyle yaparızfrom("file:/testfolder/out/?filter=#testFileFilter")
.routeId("testRoute")
.to("file:/testfolder/in/")
.end();
include Alanı
İsim filtresi içindirÖrnek
Şöyle yaparız
from("file:/testfolder/out/?include=test_files.*")
.routeId("testRoute")
.to("file:/testfolder/in/")
.end();
noop AlanıAçıklaması şöyle
'noop' configuration means that the files in the src/main/data directory should not be moved or deleted.
Örnek - Dosyayı ActiveMQ'ya taşır
Şöyle yaparız
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("file:input_box?noop=true")
.to("activemq:queue:my_queue");
}
});
readLock Alanı
Şöyle yaparız
file://${my.folder}?readLock=changed&readLockMinAge=${minAge}
&inProgressRepository=#messageIdRepository&delay=${delay}&include=${include}
Hiç yorum yok:
Yorum Gönder