2024-03-25 12:28:05 +00:00
|
|
|
package com.baeldung.apachecamellogging;
|
|
|
|
|
|
2024-03-26 12:28:14 +00:00
|
|
|
import org.apache.camel.LoggingLevel;
|
2024-03-25 12:28:05 +00:00
|
|
|
import org.apache.camel.builder.RouteBuilder;
|
|
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
public class FileCopierCamelRoute extends RouteBuilder {
|
|
|
|
|
|
2024-03-26 12:28:14 +00:00
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(FileCopierCamelRoute.class);
|
2024-03-25 12:28:05 +00:00
|
|
|
|
|
|
|
|
public void configure() {
|
|
|
|
|
from("file:data/inbox?noop=true").log("We got an incoming file ${file:name} containing: ${body}")
|
|
|
|
|
.to("log:com.baeldung.apachecamellogging?level=INFO")
|
2024-03-26 12:28:14 +00:00
|
|
|
.process(process -> {
|
|
|
|
|
LOGGER.info("We are passing the message to a FileProcesor bean to capitalize the message body");
|
2024-03-25 12:28:05 +00:00
|
|
|
})
|
|
|
|
|
.bean(FileProcessor.class)
|
|
|
|
|
.to("file:data/outbox")
|
2024-03-26 12:28:14 +00:00
|
|
|
.to("log:com.baeldung.apachecamellogging?showBodyType=false&maxChars=20")
|
|
|
|
|
.log(LoggingLevel.DEBUG, "Output Process", "The Process ${id}")
|
2024-03-28 05:37:03 +00:00
|
|
|
.log("Successfully transfer file: ${file:name}");
|
2024-03-25 12:28:05 +00:00
|
|
|
}
|
|
|
|
|
}
|