Interface Processor<KIn,VIn,KOut,VOut>

Type Parameters:
KIn - the type of input keys
VIn - the type of input values
KOut - the type of output keys
VOut - the type of output values
All Known Implementing Classes:
ContextualProcessor, ForeachProcessor

public interface Processor<KIn,VIn,KOut,VOut>
A processor of key-value pair records.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Close this processor and clean up any resources.
    default void
    Initialize this processor with the given context.
    void
    process(Record<KIn,VIn> record)
    Process the record.
  • Method Details

    • init

      default void init(ProcessorContext<KOut,VOut> context)
      Initialize this processor with the given context. The framework ensures this is called once per processor when the topology that contains it is initialized. When the framework is done with the processor, close() will be called on it; the framework may later re-use the processor by calling #init() again.

      The provided context can be used to access topology and record meta data, to schedule a method to be called periodically and to access attached StateStores.

      Parameters:
      context - the context; may not be null
    • process

      void process(Record<KIn,VIn> record)
      Process the record. Note that record metadata is undefined in cases such as a forward call from a punctuator.
      Parameters:
      record - the record to process
    • close

      default void close()
      Close this processor and clean up any resources. Be aware that #close() is called after an internal cleanup. Thus, it is not possible to write anything to Kafka as underlying clients are already closed. The framework may later re-use this processor by calling #init() on it again.

      Note: Do not close any streams managed resources, like StateStores here, as they are managed by the library.