File adapter in APPEND mode doesn't work.
Hi,
I'm using newest Spring Integration 2.2.0.RELEASE and trying to write to file in APPEND mode. I generate message as following:
Code:
private void generateMessagesFromFolder(File folder, String channelToSend) {
MessageChannel channel = (MessageChannel) context.getBean(channelToSend);
for (File file : folder.listFiles()) {
Message<File> msg = MessageBuilder.withPayload(file)
.build();
channel.send(msg);
}
}
File adapter is configures as following:
Code:
<int-file:outbound-channel-adapter id="eventsExport"
channel="EventsExportChannel"
directory="file:C:/Test/Export"
mode="APPEND" />
Files are XML, therefore, before sending to the adapter, I do some pretty simple XSLT transformation.
Code:
<int:chain input-channel="PreExportChannel" output-channel="EventsExportChannel">
<int-file:file-to-string-transformer delete-files="true" />
<int-xml:xslt-transformer xsl-resource="EventToCSV.xsl" />
</int:chain>
When I do the same without APPEND mode, everything works fine, except that the result file contains only the info from the last message. I checked with debugger and the error seems to be raised by the attempt to get file lock.
What am I doing wrong?
As a side question: I also tried to workaround the problem with Aggregator (which I put as the last step in the chaing), therefore procuding the message with mannually set correlationId, sequence size and number, but didn't succeed, since my aggregate method never got called, resulting in TargetInvocationException.
Any help is much appreciated!