Resource management for data streams
When writing any Java program, proper resource management should always be a consideration. Programs that consume too many resources or fail to release resources properly can cause serious problems for their execution environment. This is particularly true for programs sharing the same resources, such as a connector.
Introduction
Connectors execute in the Atom and share resources with other connectors and the Atom itself. If a single connector operation consumes too many resources, the runtime can quickly become overwhelmed. For example, if a connector operation consumes one-fifth of the available heap, it only takes five operations running concurrently to consume all of the available resources for any other connectors and the runtime.
Review some examples of resource management so you can avoid these problems. In particular, we'll focus on the consumption and management of input and output data streams. The first set of examples illustrate improper resource management within a single operation. The second set of examples demonstrate how you could improve the code and the potential use case of each solution.
The information and best practices discussed here are required for a connector to be approved by and publicly released (visible to all users). Although not required for a private connector, this information is still highly recommended.