Class MultiDemandPausing<T>

java.lang.Object
io.smallrye.mutiny.groups.MultiDemandPausing<T>
Type Parameters:
T - the type of items emitted by the stream

public class MultiDemandPausing<T> extends Object
Configures a pausable Multi stream.

This class allows configuring how a stream behaves when paused, including:

  • Initial pause state
  • Late subscription (delaying upstream subscription until resumed)
  • Buffer strategy (BUFFER, DROP, or IGNORE)
  • Buffer size limits
  • Constructor Details

    • MultiDemandPausing

      public MultiDemandPausing(AbstractMulti<T> upstream)
  • Method Details

    • paused

      @CheckReturnValue public MultiDemandPausing<T> paused(boolean paused)
      Sets the initial pause state of the stream.

      When set to true, the stream starts paused and no items will flow until DemandPauser.resume() is called.

      Parameters:
      paused - true to start paused, false to start flowing (default)
      Returns:
      this configuration instance
    • lateSubscription

      @CheckReturnValue public MultiDemandPausing<T> lateSubscription(boolean lateSubscription)
      Delays the upstream subscription until the stream is resumed.

      By default, the upstream subscription happens immediately even when starting paused. When lateSubscription is true and the stream starts paused, the upstream subscription is delayed until DemandPauser.resume() is called.

      This is useful for hot sources where you want to avoid missing early items that would be emitted before you're ready to process them.

      Parameters:
      lateSubscription - true to delay subscription until resumed, false for immediate subscription (default)
      Returns:
      this configuration instance
    • bufferSize

      @CheckReturnValue public MultiDemandPausing<T> bufferSize(int bufferSize)
      Sets the maximum buffer size for already-requested items when using BackPressureStrategy.BUFFER.

      When the stream is paused, items that were already requested from upstream can be buffered.

      Note: The buffer only holds items that were already requested from upstream before pausing. When paused, no new requests are issued to upstream.

      Parameters:
      bufferSize - the maximum buffer size, must be positive
      Returns:
      this configuration instance
    • bufferUnconditionally

      @CheckReturnValue public MultiDemandPausing<T> bufferUnconditionally()
      Sets the buffer size for already-requested items to unbounded when using BackPressureStrategy.BUFFER.

      When the stream is paused, items that were already requested from upstream can be buffered.

      Returns:
      this configuration instance
    • bufferStrategy

      @CheckReturnValue public MultiDemandPausing<T> bufferStrategy(BackPressureStrategy bufferStrategy)
      Sets the strategy for handling already-requested items while paused.

      Available strategies:

      Parameters:
      bufferStrategy - the buffer strategy, must not be null
      Returns:
      this configuration instance
    • using

      @CheckReturnValue public Multi<T> using(DemandPauser pauser)
      Sets the demand pauser and return the new Multi.
      Parameters:
      pauser - the pauser handle, must not be null
      Returns:
      the new Multi