- Type Parameters:
T- the type of items emitted by the stream
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbufferSize(int bufferSize) Sets the maximum buffer size for already-requested items when usingBackPressureStrategy.BUFFER.bufferStrategy(BackPressureStrategy bufferStrategy) Sets the strategy for handling already-requested items while paused.Sets the buffer size for already-requested items to unbounded when usingBackPressureStrategy.BUFFER.lateSubscription(boolean lateSubscription) Delays the upstream subscription until the stream is resumed.paused(boolean paused) Sets the initial pause state of the stream.using(DemandPauser pauser) Sets the demand pauser and return the newMulti.
-
Constructor Details
-
MultiDemandPausing
-
-
Method Details
-
paused
Sets the initial pause state of the stream.When set to
true, the stream starts paused and no items will flow untilDemandPauser.resume()is called.- Parameters:
paused-trueto start paused,falseto start flowing (default)- Returns:
- this configuration instance
-
lateSubscription
Delays the upstream subscription until the stream is resumed.By default, the upstream subscription happens immediately even when starting paused. When
lateSubscriptionistrueand the stream startspaused, the upstream subscription is delayed untilDemandPauser.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-trueto delay subscription until resumed,falsefor immediate subscription (default)- Returns:
- this configuration instance
-
bufferSize
Sets the maximum buffer size for already-requested items when usingBackPressureStrategy.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
Sets the buffer size for already-requested items to unbounded when usingBackPressureStrategy.BUFFER.When the stream is paused, items that were already requested from upstream can be buffered.
- Returns:
- this configuration instance
-
bufferStrategy
Sets the strategy for handling already-requested items while paused.Available strategies:
BackPressureStrategy.BUFFER: Buffer items while paused, deliver when resumed (default)BackPressureStrategy.DROP: Drop items while paused, continue with fresh items when resumedBackPressureStrategy.IGNORE: Continue delivering already-requested items even while paused
- Parameters:
bufferStrategy- the buffer strategy, must not benull- Returns:
- this configuration instance
-
using
Sets the demand pauser and return the newMulti.- Parameters:
pauser- the pauser handle, must not benull- Returns:
- the new
Multi
-