Class PubSubConfiguration

java.lang.Object
com.google.cloud.spring.pubsub.core.PubSubConfiguration
Direct Known Subclasses:
GcpPubSubProperties

public class PubSubConfiguration extends Object
Properties for Publisher or Subscriber specific configurations.
  • Field Details

    • DEFAULT_EXECUTOR_THREADS

      public static final int DEFAULT_EXECUTOR_THREADS
      Default number of executor threads.
      See Also:
  • Constructor Details

    • PubSubConfiguration

      public PubSubConfiguration()
  • Method Details

    • getSubscriber

      public PubSubConfiguration.Subscriber getSubscriber()
    • getPublisher

      public PubSubConfiguration.Publisher getPublisher()
    • getHealth

      public PubSubConfiguration.Health getHealth()
    • setSubscription

      public void setSubscription(Map<String,PubSubConfiguration.Subscriber> subscriberProperties)
      This method will be called by Spring Framework when binding user properties. Also potentially useful for tests.
      Parameters:
      subscriberProperties - map of user-defined properties.
    • getFullyQualifiedSubscriberProperties

      public Map<com.google.pubsub.v1.ProjectSubscriptionName,PubSubConfiguration.Subscriber> getFullyQualifiedSubscriberProperties()
      Returns an immutable map of subscription properties keyed by the fully-qualified ProjectSubscriptionName.

      Cannot be called before initialize(String).

      Returns:
      map of subscription properties
    • initialize

      public void initialize(String defaultProjectId)
      Standardizes all subscription properties to be keyed by their fully qualified subscription names. Not thread-safe.

      If a `fully-qualified-name` property is present, it is used as a key for all subscription properties under the same group. Otherwise, the provided configuration group key is assumed to be the short subscription name in the current project.

      Parameters:
      defaultProjectId - Project to use with short subscription names
    • getSubscriptionProperties

      public PubSubConfiguration.Subscriber getSubscriptionProperties(com.google.pubsub.v1.ProjectSubscriptionName projectSubscriptionName)
      Returns properties for the specified fully-qualified ProjectSubscriptionName.
      Parameters:
      projectSubscriptionName - fully-qualified ProjectSubscriptionName
      Returns:
      user-provided subscription properties
    • computeSubscriberFlowControlSettings

      public PubSubConfiguration.FlowControl computeSubscriberFlowControlSettings(com.google.pubsub.v1.ProjectSubscriptionName projectSubscriptionName)
      Computes flow control settings to use. The subscription-specific property takes precedence if both global and subscription-specific properties are set. If subscription-specific settings are not set then global settings are picked.
      Parameters:
      projectSubscriptionName - Fully qualified subscription name
      Returns:
      flow control settings defaulting to global where not provided
    • computeParallelPullCount

      public Integer computeParallelPullCount(String subscriptionName, String projectId)
      Computes parallel pull count. The subscription-specific property takes precedence if both global and subscription-specific properties are set. If subscription-specific configuration is not set then the global configuration is picked.
      Parameters:
      subscriptionName - subscription name
      projectId - project id
      Returns:
      parallel pull count
    • computeRetryableCodes

      public com.google.api.gax.rpc.StatusCode.Code[] computeRetryableCodes(String subscriptionName, String projectId)
      Retrieves collection of retryable codes from configuration. The subscription-specific property takes precedence if both global and subscription-specific properties are set. If subscription-specific configuration is not set then the global configuration is picked.
      Parameters:
      subscriptionName - subscription name
      projectId - project id
      Returns:
      retryable codes
    • computeMaxAckExtensionPeriod

      public Long computeMaxAckExtensionPeriod(String subscriptionName, String projectId)
      Computes the max extension period. The subscription-specific property takes precedence if both global and subscription-specific properties are set. If none are set then the default (0) is returned.
      Parameters:
      subscriptionName - subscription name
      projectId - project id
      Returns:
      max extension period
    • computeMinDurationPerAckExtension

      @Nullable public Long computeMinDurationPerAckExtension(String subscriptionName, String projectId)
      Computes the lower bound for a single mod ack extension period. The subscription-specific property takes precedence if both global and subscription-specific properties are set. If none are set then the default (0) is returned.
      Parameters:
      subscriptionName - subscription name
      projectId - project id
      Returns:
      min duration per ack extension
    • computeMaxDurationPerAckExtension

      @Nullable public Long computeMaxDurationPerAckExtension(String subscriptionName, String projectId)
      Computes the upper bound for a single mod ack extension period. The subscription-specific property takes precedence if both global and subscription-specific properties are set. If none are set then the default (0) is returned.
      Parameters:
      subscriptionName - subscription name
      projectId - project id
      Returns:
      max duration per ack extension
    • computePullEndpoint

      public String computePullEndpoint(String subscriptionName, String projectId)
      Returns the pull endpoint. The subscription-specific property takes precedence if both global and subscription-specific properties are set. If subscription-specific configuration is not set then the global configuration is picked.
      Parameters:
      subscriptionName - subscription name
      projectId - project id
      Returns:
      pull endpoint
    • computeSubscriberRetrySettings

      public PubSubConfiguration.Retry computeSubscriberRetrySettings(com.google.pubsub.v1.ProjectSubscriptionName projectSubscriptionName)
      Computes the retry settings. The subscription-specific property takes precedence if both global and subscription-specific properties are set. If subscription-specific settings are not set then the global settings are picked.
      Parameters:
      projectSubscriptionName - The fully qualified subscription name
      Returns:
      retry settings