Class PubSubSource.PubSubSourceBuilder<OUT>
- java.lang.Object
-
- org.apache.flink.streaming.connectors.gcp.pubsub.PubSubSource.PubSubSourceBuilder<OUT>
-
- Type Parameters:
OUT- The type of objects which will be read
- All Implemented Interfaces:
PubSubSource.ProjectNameBuilder<OUT>,PubSubSource.SubscriptionNameBuilder<OUT>
- Enclosing class:
- PubSubSource<OUT>
public static class PubSubSource.PubSubSourceBuilder<OUT> extends Object implements PubSubSource.ProjectNameBuilder<OUT>, PubSubSource.SubscriptionNameBuilder<OUT>
Builder to create PubSubSource.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PubSubSource<OUT>build()Actually build the desired instance of the PubSubSourceBuilder.PubSubSource.PubSubSourceBuilder<OUT>withCredentials(com.google.auth.Credentials credentials)Set the credentials.PubSubSource.PubSubSourceBuilder<OUT>withMessageRateLimit(int messagePerSecondRateLimit)Set a limit on the rate of messages per second received.PubSubSource.SubscriptionNameBuilder<OUT>withProjectName(String projectName)Set the project name of the subscription to pull messages from.PubSubSource.PubSubSourceBuilder<OUT>withPubSubSubscriberFactory(int maxMessagesPerPull, java.time.Duration perRequestTimeout, int retries)There is a default PubSubSubscriber factory that uses gRPC to pull in PubSub messages.PubSubSource.PubSubSourceBuilder<OUT>withPubSubSubscriberFactory(PubSubSubscriberFactory pubSubSubscriberFactory)Set a PubSubSubscriberFactory This allows for custom Subscriber options to be set.PubSubSource.PubSubSourceBuilder<OUT>withSubscriptionName(String subscriptionName)Set the subscription name of the subscription to pull messages from.
-
-
-
Method Detail
-
withProjectName
public PubSubSource.SubscriptionNameBuilder<OUT> withProjectName(String projectName)
Description copied from interface:PubSubSource.ProjectNameBuilderSet the project name of the subscription to pull messages from.- Specified by:
withProjectNamein interfacePubSubSource.ProjectNameBuilder<OUT>
-
withSubscriptionName
public PubSubSource.PubSubSourceBuilder<OUT> withSubscriptionName(String subscriptionName)
Description copied from interface:PubSubSource.SubscriptionNameBuilderSet the subscription name of the subscription to pull messages from.- Specified by:
withSubscriptionNamein interfacePubSubSource.SubscriptionNameBuilder<OUT>
-
withCredentials
public PubSubSource.PubSubSourceBuilder<OUT> withCredentials(com.google.auth.Credentials credentials)
Set the credentials. If this is not used then the credentials are picked up from the environment variables.- Parameters:
credentials- the Credentials needed to connect.- Returns:
- The current PubSubSourceBuilder instance
-
withPubSubSubscriberFactory
public PubSubSource.PubSubSourceBuilder<OUT> withPubSubSubscriberFactory(PubSubSubscriberFactory pubSubSubscriberFactory)
Set a PubSubSubscriberFactory This allows for custom Subscriber options to be set.DefaultPubSubSubscriberFactoryis the default.- Parameters:
pubSubSubscriberFactory- A factory to create aSubscriber- Returns:
- The current PubSubSourceBuilder instance
-
withPubSubSubscriberFactory
public PubSubSource.PubSubSourceBuilder<OUT> withPubSubSubscriberFactory(int maxMessagesPerPull, java.time.Duration perRequestTimeout, int retries)
There is a default PubSubSubscriber factory that uses gRPC to pull in PubSub messages. This method can be used to tune this default factory. Note this will not work in combination with a custom PubSubSubscriber factory.- Parameters:
maxMessagesPerPull- the number of messages pulled per request. Default: 100perRequestTimeout- the timeout per request. Default: 15 secondsretries- the number of retries when requests fail- Returns:
- The current PubSubSourceBuilder instance
-
withMessageRateLimit
public PubSubSource.PubSubSourceBuilder<OUT> withMessageRateLimit(int messagePerSecondRateLimit)
Set a limit on the rate of messages per second received. This limit is per parallel instance of the source function. Default is set to 100000 messages per second.- Parameters:
messagePerSecondRateLimit- the message per second rate limit.
-
build
public PubSubSource<OUT> build() throws IOException
Actually build the desired instance of the PubSubSourceBuilder.- Returns:
- a brand new SourceFunction
- Throws:
IOException- in case of a problem getting the credentialsIllegalArgumentException- in case required fields were not specified.
-
-