Created
April 21, 2021 12:53
-
-
Save kunupat/51ee3f986ab22738dbf427172c968971 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.io.FilenameFilter; | |
import org.apache.camel.builder.RouteBuilder; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.stereotype.Component; | |
@Component | |
public class FilesAggregatorRoute extends RouteBuilder { | |
@Autowired | |
FileAggregationStrategy fileAggregationStrategy; | |
@Override | |
public void configure() throws Exception { | |
String inputFilePath = System.getProperty("user.home") + "/data/out/jsons/"; | |
String outputFilePath = System.getProperty("user.home") + "/data/out/processed/"; | |
File file = new File(inputFilePath); | |
int numberOfFiles= file.listFiles(new FilenameFilter() { | |
@Override | |
public boolean accept(File dir, String name) { | |
return name.endsWith(".json"); | |
} | |
}).length; | |
System.out.println(numberOfFiles); | |
from("direct:start") | |
.noAutoStartup() | |
.loop(numberOfFiles) | |
.pollEnrich("file:" + inputFilePath + "?noop=true",fileAggregationStrategy) | |
.to("file:" + outputFilePath + "?fileName=customers.json") | |
.routeId("filesAggregationRoute"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment