Skip to content

Instantly share code, notes, and snippets.

@kunupat
Last active April 21, 2021 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kunupat/77d534be7b149221a8bff792d47e91d1 to your computer and use it in GitHub Desktop.
Save kunupat/77d534be7b149221a8bff792d47e91d1 to your computer and use it in GitHub Desktop.
import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;
@Component
public class FileSplitterRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
System.out.println("Configuring camel routes...");
String inputFilePath = System.getProperty("user.home") + "/data/input/" ;
String outputFilePath = System.getProperty("user.home") + "/data/out/" ;
from("direct:start")
.noAutoStartup()
.pollEnrich("file://" + inputFilePath + "?noop=true&fileName=customers.csv")
.split().tokenize("\n",100)
.to("file://" + outputFilePath + "?fileName=customers_"+ "${header.CamelSplitIndex}" + ".csv")
.routeId("fileSplitterRoute")
.end();
System.out.println("Configured camel routes...");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment