Class PubSubPublisherTemplate

java.lang.Object
com.google.cloud.spring.pubsub.core.publisher.PubSubPublisherTemplate
All Implemented Interfaces:
PubSubPublisherOperations

public class PubSubPublisherTemplate extends Object implements PubSubPublisherOperations
Default implementation of PubSubPublisherOperations.

The main Google Cloud Pub/Sub integration component for publishing to topics.

Since:
1.1
  • Constructor Details

  • Method Details

    • getMessageConverter

      public PubSubMessageConverter getMessageConverter()
    • setMessageConverter

      public void setMessageConverter(PubSubMessageConverter pubSubMessageConverter)
    • publish

      public <T> CompletableFuture<String> publish(String topic, T payload, Map<String,String> headers)
      Uses the configured message converter to first convert the payload and headers to a PubsubMessage and then publish it.
      Specified by:
      publish in interface PubSubPublisherOperations
      Type Parameters:
      T - the type of the payload to publish
      Parameters:
      topic - short topic name, e.g., "topicName", or the fully-qualified topic name in the projects/[project_name]/topics/[topic_name] format
      payload - an object that will be serialized and sent
      headers - the headers to publish
      Returns:
      the listenable future of the call
    • publish

      public <T> CompletableFuture<String> publish(String topic, T payload)
      Description copied from interface: PubSubPublisherOperations
      Send a message to Pub/Sub.
      Specified by:
      publish in interface PubSubPublisherOperations
      Type Parameters:
      T - the type of the payload to publish
      Parameters:
      topic - short topic name, e.g., "topicName", or the fully-qualified topic name in the projects/[project_name]/topics/[topic_name] format
      payload - an object that will be serialized and sent
      Returns:
      the listenable future of the call
    • publish

      public CompletableFuture<String> publish(String topic, com.google.pubsub.v1.PubsubMessage pubsubMessage)
      Description copied from interface: PubSubPublisherOperations
      Send a message to Pub/Sub.
      Specified by:
      publish in interface PubSubPublisherOperations
      Parameters:
      topic - short topic name, e.g., "topicName", or the fully-qualified topic name in the projects/[project_name]/topics/[topic_name] format
      pubsubMessage - a Google Cloud Pub/Sub API message
      Returns:
      the listenable future of the call
    • getPublisherFactory

      public PublisherFactory getPublisherFactory()