Interface StreamPublisher

All Known Subinterfaces:
ConsumerRecordToStreamPublisherAdapter
All Known Implementing Classes:
KafkaStreamPublisher, StreamPublisherBase

public interface StreamPublisher
Chunk-oriented producer for streams of data.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Flush any accumulated data in this publisher to the consumer, by invoking its accept method.
    void
    register(@NotNull StreamConsumer consumer)
    Register a consumer whose accept method will be used when sufficient data is accumulated, or on flush().
    void
    Shutdown this StreamPublisher.
  • Method Details

    • register

      void register(@NotNull @NotNull StreamConsumer consumer)
      Register a consumer whose accept method will be used when sufficient data is accumulated, or on flush(). Implementations should also be sure to deliver errors to the registered consumer via its acceptFailure method.

      consumer must typically be primed to accept the same chunk types that this produces, in the same order.

      consumer should ensure that this is shutdown when it is no longer needed.

      Parameters:
      consumer - The consumer
      Throws:
      IllegalStateException - If a consumer has already been registered for this producer
    • flush

      void flush()
      Flush any accumulated data in this publisher to the consumer, by invoking its accept method.
      ApiNote:
      This method has multiple uses, but its presence on the interface is to allow the registered consumer to "poll" for new data.
    • shutdown

      void shutdown()
      Shutdown this StreamPublisher. Implementations should stop publishing new data and release any related resources as soon as practicable.
      ApiNote:
      This method should be invoked only by the registered consumer when it will no longer consume new data, or by the constructing code if no consumer will ever be registered.