There is no bug. This is a common use case. Can you post your revised code?
There is no bug. This is a common use case. Can you post your revised code?
Please find attached snippet of modified writer. I have configured batch in order to have 1 writer and print only AttribA list. But my requirement is each List of AttribA should get printed in separate output file. But still i am getting same message 'Item strean already closed...........'
You need to get rid of the CompositeItemStream stuff. The CompositeItemStream is trying to manage your FFIW for you. However, this is not what you want. Inside your write() method you are manually opening and closing the FFIW. You do not want the framework to try to open/update/close the FFIW.
That's exactly what the code sample I provided before will do. It is saying that for each item, create a new FFIW, set a new resource (with a new filename), open it, write to it, and close it. All of which is handled in the write() method.
There is a bit progress. Now i am not getting mesage 'Stream already closed' because now i am creating reference of FileItemWriter in the write() method itself, opening it, writing data to it and then closing it.
Is there a way by which CompositeItemStream can be used to write multiple files where opening/closing of FFIW is managed by framework itself. Each and every time CompanyDTO object comes to the writer a new file should get created.
Using ItemStream to have the framework manage opening/closing is the standard way to use Spring Batch. However, this does not apply to your situation. The reason is because the scope of your file is smaller than the write() method. Since you must open and close more than one file within one call to write() there is no way that the framework could do it for you. But you should not consider this to be a problem; you simply have different requirements than the typical batch job.