Class EventOutputStreams

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class EventOutputStreams
    extends Object
    implements Closeable
    An factory for OutputStream instances that can concurrently write to the same file and do lots of other wonderful magical things (excluding changing the baby's nappy).
    • Output is collected in batches, one batch per thread and flushed periodically.
    • The file is only opened when actually writing.
    • The file is rotated if it gets too big.
    • You can close it over and over, it will auto re-open on next write!
    The primary intended use case is for event processing with FolderComputation.createEventsListener() where there may be multiple concurrent events in flight and we need to:
    • Try to keep each events log messages close together, hence the batching
    • Rotate after it gets too big
    • Not hold the file open indefinitely - ideally only when writing so that it can be moved by other processes