Class Publisher.Builder (1.118.0)

public static final class Publisher.Builder

A builder of Publishers.

Inheritance

java.lang.Object > Publisher.Builder

Static Methods

getDefaultBatchingSettings()

public static BatchingSettings getDefaultBatchingSettings()

Returns the default BatchingSettings used by the client if settings are not provided.

Returns
TypeDescription
BatchingSettings

Methods

build()

public Publisher build()
Returns
TypeDescription
Publisher
Exceptions
TypeDescription
IOException

setBatchingSettings(BatchingSettings batchingSettings)

public Publisher.Builder setBatchingSettings(BatchingSettings batchingSettings)
Parameter
NameDescription
batchingSettingsBatchingSettings
Returns
TypeDescription
Publisher.Builder

setChannelProvider(TransportChannelProvider channelProvider)

public Publisher.Builder setChannelProvider(TransportChannelProvider channelProvider)

ChannelProvider to use to create Channels, which must point at Cloud Pub/Sub endpoint.

For performance, this client benefits from having multiple underlying connections. See com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.Builder#setPoolSize(int).

Parameter
NameDescription
channelProviderTransportChannelProvider
Returns
TypeDescription
Publisher.Builder

setCompressionBytesThreshold(long compressionBytesThreshold)

public Publisher.Builder setCompressionBytesThreshold(long compressionBytesThreshold)

Sets the threshold (in bytes) above which messages are compressed for transport. Only takes effect if setEnableCompression(true) is also called."

Parameter
NameDescription
compressionBytesThresholdlong
Returns
TypeDescription
Publisher.Builder

setCredentialsProvider(CredentialsProvider credentialsProvider)

public Publisher.Builder setCredentialsProvider(CredentialsProvider credentialsProvider)

CredentialsProvider to use to create Credentials to authenticate calls.

Parameter
NameDescription
credentialsProviderCredentialsProvider
Returns
TypeDescription
Publisher.Builder

setEnableCompression(boolean enableCompression)

public Publisher.Builder setEnableCompression(boolean enableCompression)

Gives the ability to enable transport compression.

Parameter
NameDescription
enableCompressionboolean
Returns
TypeDescription
Publisher.Builder

setEnableMessageOrdering(boolean enableMessageOrdering)

public Publisher.Builder setEnableMessageOrdering(boolean enableMessageOrdering)

Sets the message ordering option.

Parameter
NameDescription
enableMessageOrderingboolean
Returns
TypeDescription
Publisher.Builder

setEndpoint(String endpoint)

public Publisher.Builder setEndpoint(String endpoint)

Gives the ability to override the gRPC endpoint.

Parameter
NameDescription
endpointString
Returns
TypeDescription
Publisher.Builder

setExecutorProvider(ExecutorProvider executorProvider)

public Publisher.Builder setExecutorProvider(ExecutorProvider executorProvider)

Gives the ability to set a custom executor to be used by the library.

Parameter
NameDescription
executorProviderExecutorProvider
Returns
TypeDescription
Publisher.Builder

setHeaderProvider(HeaderProvider headerProvider)

public Publisher.Builder setHeaderProvider(HeaderProvider headerProvider)

Sets the static header provider. The header provider will be called during client construction only once. The headers returned by the provider will be cached and supplied as is for each request issued by the constructed client. Some reserved headers can be overridden (e.g. Content-Type) or merged with the default value (e.g. User-Agent) by the underlying transport layer.

Parameter
NameDescription
headerProviderHeaderProvider

the header provider

Returns
TypeDescription
Publisher.Builder

the builder

setRetrySettings(RetrySettings retrySettings)

public Publisher.Builder setRetrySettings(RetrySettings retrySettings)

Configures the Publisher's retry parameters.

Parameter
NameDescription
retrySettingsRetrySettings
Returns
TypeDescription
Publisher.Builder

setTransform(ApiFunction<PubsubMessage,PubsubMessage> messageTransform)

public Publisher.Builder setTransform(ApiFunction<PubsubMessage,PubsubMessage> messageTransform)

Gives the ability to set an ApiFunction that will transform the PubsubMessage before it is sent

Parameter
NameDescription
messageTransformApiFunction<PubsubMessage,PubsubMessage>
Returns
TypeDescription
Publisher.Builder