public class PubSubPublisherTemplate extends Object implements PubSubPublisherOperations
PubSubPublisherOperations
.
The main Google Cloud Pub/Sub integration component for publishing to topics.
Constructor and Description |
---|
PubSubPublisherTemplate(PublisherFactory publisherFactory)
Default
PubSubPublisherTemplate constructor that uses SimplePubSubMessageConverter
to serialize and deserialize payloads. |
Modifier and Type | Method and Description |
---|---|
PubSubMessageConverter |
getMessageConverter() |
PublisherFactory |
getPublisherFactory() |
org.springframework.util.concurrent.ListenableFuture<String> |
publish(String topic,
com.google.pubsub.v1.PubsubMessage pubsubMessage)
Send a message to Pub/Sub.
|
<T> org.springframework.util.concurrent.ListenableFuture<String> |
publish(String topic,
T payload)
Send a message to Pub/Sub.
|
<T> org.springframework.util.concurrent.ListenableFuture<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. |
void |
setMessageConverter(PubSubMessageConverter pubSubMessageConverter) |
public PubSubPublisherTemplate(PublisherFactory publisherFactory)
PubSubPublisherTemplate
constructor that uses SimplePubSubMessageConverter
to serialize and deserialize payloads.publisherFactory
- the Publisher
factory to
publish to topics.public PubSubMessageConverter getMessageConverter()
public void setMessageConverter(PubSubMessageConverter pubSubMessageConverter)
public <T> org.springframework.util.concurrent.ListenableFuture<String> publish(String topic, T payload, Map<String,String> headers)
PubsubMessage
and then publish it.publish
in interface PubSubPublisherOperations
T
- the type of the payload to publishtopic
- canonical topic name, e.g., "topicName", or the fully-qualified topic name in the
projects/<project_name>/topics/<topic_name>
formatpayload
- an object that will be serialized and sentheaders
- the headers to publishpublic <T> org.springframework.util.concurrent.ListenableFuture<String> publish(String topic, T payload)
PubSubPublisherOperations
publish
in interface PubSubPublisherOperations
T
- the type of the payload to publishtopic
- canonical topic name, e.g., "topicName", or the fully-qualified topic name in the
projects/<project_name>/topics/<topic_name>
formatpayload
- an object that will be serialized and sentpublic org.springframework.util.concurrent.ListenableFuture<String> publish(String topic, com.google.pubsub.v1.PubsubMessage pubsubMessage)
PubSubPublisherOperations
publish
in interface PubSubPublisherOperations
topic
- canonical topic name, e.g., "topicName", or the fully-qualified topic name in the
projects/<project_name>/topics/<topic_name>
formatpubsubMessage
- a Google Cloud Pub/Sub API messagepublic PublisherFactory getPublisherFactory()
Copyright © 2021. All rights reserved.