FileOutputStreamResouce is a
AbstractOutputStreamResource implementation
that handles file output streams.
Example configuration:
<resource-config selector="order-item">
<resource>org.milyn.io.file.FileOutputStreamResource</resource>
<param name="resourceName">resourceName</param>
<param name="fileNamePattern">orderitem-${order.orderId}-${order.orderItem.itemId}.xml</param>
<param name="destinationDirectoryPattern">order-${order.orderId}</param>
<param name="listFileNamePattern">orderitems-${order.orderId}.lst</param>
</resource-config>
Optional properties (default values shown):
<param name="highWaterMark">200</param>
<param name="highWaterMarkTimeout">60000</param>
Description of configuration properties:
- resourceName: the name of this resouce. Will be used to identify this resource.
- fileNamePattern: is the pattern that will be used to generate file names. The file is
created in the destinationDirectory. Supports templating.
- listFileNamePattern: is name of the file that will contain the file names generated by this
configuration. The file is created in the destinationDirectory. Supports templating.
- destinationDirectoryPattern: is the destination directory for files created by this router. Supports templating.
- highWaterMark: max number of output files in the destination directory at any time.
- highWaterMarkTimeout: number of ms to wait for the system to process files in the destination
directory so that the number of files drops below the highWaterMark.
- highWaterMarkPollFrequency: number of ms to wait between checks on the High Water Mark, while
waiting for it to drop.
- closeOnCondition: An MVEL expression. If it returns true then the output stream is closed on the visitAfter event
else it is kept open. If the expression is not set then output stream is closed by default.
- append: Will append to the file specified with the 'fileNamePattern' property. This is useful
for example when you want to append to a single csv file.
When does a new file get created?
As soon as an object tries to retrieve the Writer or the OutputStream from this OutputStreamResource and
the Stream isn't open then a new file is created. Using the 'closeOnCondition' property you can control
when a stream get closed. As long as the stream isn't closed, the same file is used to write too. At then
end of the filter process the stream always gets closed. Nothing stays open.