This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Aggregator to multiple file outputs

Nov 9th, 2012, 04:45 PM

Hi

I have a usecase where the result of Aggregation needs to be written to a single output file or multiple output files. This decision depends on the Threshold values of current file being written.
Can this be achieved?

In general, yes, you can route on some condition (e.g. aggregate size of the collection). On one path, split the payload and send the each message to a file adapter that appends to a single file. On the other path, split the payload and route to an adapter that creates a new file for each message.

Comment

Sorry for not being clear.
If we have like 1000 items as a result of Aggregation, The file threshold says each file can allow 800 items, so i need 800 written to the first file and the remaining written to the second file. Hope this is clear.

Comment

Well, the question is what an "item" is. But, if it's as simple as that...

All you need is a custom splitter that first splits the result of the aggregation into collections with <= 800 iterms; then another splitter to split those payloads, then a file outbound adapter that appends.

->splitInto800s->splitter->file-outbound-adapter(with append)

Comment

The "item" or the object i have in the aggregation has an attribute of something like record count, so i need to sum up these record count within that custom splitter seems like. Will analyze more, thanks for your input.