Description
It is the responsibility of the QueryBatcher and the WriteBatcher to call any close() methods of the listeners registered with them. If the listeners had to close any resources, they can implement AutoCloseable interface and close the resources in the close() method. QueryBatcher and WriteBatcher would iterate all the listeners and call any close() methods when stopJob is called on the batcher.
Similarly, it is the responsibility of the listeners to close any resources opened by the consumers registered with them. It should implement AutoCloseable and iterate all the Consumers and call close() methods as necessary. This should be done in the close() method of the listener which would be closed by the Batcher when stopJob is called.
Batcher(QueryBatcher/WriteBatcher) -> calls the listeners' close method (which are registered with the Batcher)
Listeners -> calls the Consumers close() method (which are registered with the listeners)