public final class PubSubReactiveFactory extends Object
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).Constructor and Description |
---|
PubSubReactiveFactory(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.
|
Modifier and Type | Method and Description |
---|---|
reactor.core.publisher.Flux<AcknowledgeablePubsubMessage> |
poll(String subscriptionName,
long pollingPeriodMs)
Create an infinite stream
Flux of AcknowledgeablePubsubMessage objects. |
public PubSubReactiveFactory(PubSubSubscriberOperations subscriberOperations, reactor.core.scheduler.Scheduler scheduler)
maxMessages
is set to Integer.MAX_VALUE
.
subscriberOperations
- template for interacting with GCP Pub/Sub subscriber operations.scheduler
- scheduler to use for asynchronously retrieving Pub/Sub messages.public PubSubReactiveFactory(PubSubSubscriberOperations subscriberOperations, reactor.core.scheduler.Scheduler scheduler, int maxMessages)
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.public reactor.core.publisher.Flux<AcknowledgeablePubsubMessage> poll(String subscriptionName, long pollingPeriodMs)
Flux
of AcknowledgeablePubsubMessage
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.
subscriptionName
- subscription from which to retrieve messages.pollingPeriodMs
- how frequently to poll the source subscription in case of unlimited demand, in milliseconds.AcknowledgeablePubsubMessage
objects.Copyright © 2020 Pivotal Software, Inc.. All rights reserved.