Class PubSubPublisherTemplate
java.lang.Object
com.google.cloud.spring.pubsub.core.publisher.PubSubPublisherTemplate
- All Implemented Interfaces:
PubSubPublisherOperations
Default implementation of
PubSubPublisherOperations.
The main Google Cloud Pub/Sub integration component for publishing to topics.
- Since:
- 1.1
-
Constructor Summary
ConstructorsConstructorDescriptionPubSubPublisherTemplate(PublisherFactory publisherFactory) DefaultPubSubPublisherTemplateconstructor that usesSimplePubSubMessageConverterto serialize and deserialize payloads. -
Method Summary
Modifier and TypeMethodDescriptionSend a message to Pub/Sub.<T> CompletableFuture<String>Send a message to Pub/Sub.<T> CompletableFuture<String>Uses the configured message converter to first convert the payload and headers to aPubsubMessageand then publish it.voidsetMessageConverter(PubSubMessageConverter pubSubMessageConverter)
-
Constructor Details
-
PubSubPublisherTemplate
DefaultPubSubPublisherTemplateconstructor that usesSimplePubSubMessageConverterto serialize and deserialize payloads.- Parameters:
publisherFactory- thePublisherfactory to publish to topics.
-
-
Method Details
-
getMessageConverter
-
setMessageConverter
-
publish
Uses the configured message converter to first convert the payload and headers to aPubsubMessageand then publish it.- Specified by:
publishin interfacePubSubPublisherOperations- 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 theprojects/[project_name]/topics/[topic_name]formatpayload- an object that will be serialized and sentheaders- the headers to publish- Returns:
- the listenable future of the call
-
publish
Description copied from interface:PubSubPublisherOperationsSend a message to Pub/Sub.- Specified by:
publishin interfacePubSubPublisherOperations- 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 theprojects/[project_name]/topics/[topic_name]formatpayload- 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:PubSubPublisherOperationsSend a message to Pub/Sub.- Specified by:
publishin interfacePubSubPublisherOperations- Parameters:
topic- short topic name, e.g., "topicName", or the fully-qualified topic name in theprojects/[project_name]/topics/[topic_name]formatpubsubMessage- a Google Cloud Pub/Sub API message- Returns:
- the listenable future of the call
-
getPublisherFactory
-