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
ConstructorDescriptionPubSubPublisherTemplate
(PublisherFactory publisherFactory) DefaultPubSubPublisherTemplate
constructor that usesSimplePubSubMessageConverter
to 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 aPubsubMessage
and then publish it.void
setMessageConverter
(PubSubMessageConverter pubSubMessageConverter)
-
Constructor Details
-
PubSubPublisherTemplate
DefaultPubSubPublisherTemplate
constructor that usesSimplePubSubMessageConverter
to serialize and deserialize payloads.- Parameters:
publisherFactory
- thePublisher
factory to publish to topics.
-
-
Method Details
-
getMessageConverter
-
setMessageConverter
-
publish
Uses the configured message converter to first convert the payload and headers to aPubsubMessage
and then publish it.- Specified by:
publish
in 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:PubSubPublisherOperations
Send a message to Pub/Sub.- Specified by:
publish
in 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:PubSubPublisherOperations
Send a message to Pub/Sub.- Specified by:
publish
in 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
-