In ActivePivot 5.0, I'm monitoring a file containing my data to inject in the datastore. I want to have this single entry point, and that each change of the file updates or insert new data.
This is my configuration of the file topic:
@Bean
public CSVSource csvSource() {
// Define source
final CSVSource source = new CSVSource();
final List<String> productFileColumns = Arrays.toList("a", "b", "c");
final ICSVTopic myTopic = source.createTopic("myTopic", "path/to/my/file");
myTopic.getParserConfiguration().setSeparator(";");
source.addTopic(myTopic);
// some configuration of the csv source (threads, ...)
...
// Define channel factory
final CSVMessageChannelFactory channelFactory = new CSVMessageChannelFactory(csvSource, datastore);
...
// Listen some topics
final Map<String, String> topicsToListen = new HashMap<>();
topicsToListen.put("myTopic_Store", "myTopic");
final Listen<IFileInfo, ILineReader> listener = new Listen<>(channelFactory, topicsToListen);
listener.listen(csvSource);
}
And my code updating the file:
public void updateFile() {
final Path path = Paths.get("path/to/my/file");
// Write and truncate
Files.write(path, "1;2;3".getBytes(), StandardOpenOption.TRUNCATE_EXISTING);
// Add another data
Files.write(path, "4;5;6".getBytes(), StandardOpenOption.APPEND);
// Add another data
Files.write(path, "7;8;9".getBytes(), StandardOpenOption.APPEND);
}
My issue is that I see multiple processings of my file by the CSV source, while I expect it to be processed only once per call to #updateFile.
Note: For now, I want to update my file using Java, not manually or with another language.
Thanks for the help.