Class PubSubReactiveFactory
Flux
instances backed by GCP Pub/Sub Subscriptions.
The Scheduler
, that is given to the constructor, is used for regularly polling the
subscription, when the demand is unlimited. The scheduler is not used when there is a specific
demand (a.k.a backpressure).
- Since:
- 1.2
-
Constructor Summary
ConstructorDescriptionPubSubReactiveFactory
(PubSubSubscriberOperations subscriberOperations, reactor.core.scheduler.Scheduler scheduler) Instantiate `PubSubReactiveFactory` capable of generating subscription-based streams.PubSubReactiveFactory
(PubSubSubscriberOperations subscriberOperations, reactor.core.scheduler.Scheduler scheduler, int maxMessages) Instantiate `PubSubReactiveFactory` capable of generating subscription-based streams. -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Flux<AcknowledgeablePubsubMessage>
Create an infinite streamFlux
ofAcknowledgeablePubsubMessage
objects.
-
Constructor Details
-
PubSubReactiveFactory
public PubSubReactiveFactory(PubSubSubscriberOperations subscriberOperations, reactor.core.scheduler.Scheduler scheduler) Instantiate `PubSubReactiveFactory` capable of generating subscription-based streams.maxMessages
is set toInteger.MAX_VALUE
.- Parameters:
subscriberOperations
- template for interacting with GCP Pub/Sub subscriber operations.scheduler
- scheduler to use for asynchronously retrieving Pub/Sub messages.
-
PubSubReactiveFactory
public PubSubReactiveFactory(PubSubSubscriberOperations subscriberOperations, reactor.core.scheduler.Scheduler scheduler, int maxMessages) Instantiate `PubSubReactiveFactory` capable of generating subscription-based streams.- Parameters:
subscriberOperations
- template for interacting with GCP Pub/Sub subscriber operations.scheduler
- scheduler to use for asynchronously retrieving Pub/Sub messages.maxMessages
- max number of messages that may be pulled from the source subscription in case of unlimited demand.
-
-
Method Details
-
poll
public reactor.core.publisher.Flux<AcknowledgeablePubsubMessage> poll(String subscriptionName, long pollingPeriodMs) Create an infinite streamFlux
ofAcknowledgeablePubsubMessage
objects.The
Flux
respects backpressure by using of Pub/Sub Synchronous Pull to retrieve batches of up to the requested number of messages until the full demand is fulfilled or subscription terminated.For unlimited demand, the underlying subscription will be polled at a regular interval, requesting up to
maxMessages
messages at each poll.For specific demand, as many messages as are available will be returned immediately, with remaining demand being fulfilled in the future. Pub/Sub timeout will cause a retry with the same demand.
Any exceptions that are thrown by the Pub/Sub client will be passed as an error to the stream. The error handling operators, like
Flux.retry()
, can be used to recover and continue streaming messages.- Parameters:
subscriptionName
- subscription from which to retrieve messages.pollingPeriodMs
- how frequently to poll the source subscription in case of unlimited demand, in milliseconds.- Returns:
- infinite stream of
AcknowledgeablePubsubMessage
objects.
-