public class SimplePubSubMessageConverter extends Object implements PubSubMessageConverter
PubSubMessageConverter
that directly maps payloads of type
byte[]
, ByteString
, ByteBuffer
, and String
to Pub/Sub messages.Constructor and Description |
---|
SimplePubSubMessageConverter() |
SimplePubSubMessageConverter(Charset charset) |
Modifier and Type | Method and Description |
---|---|
<T> T |
fromPubSubMessage(com.google.pubsub.v1.PubsubMessage message,
Class<T> payloadType)
Convert the payload of a given
PubsubMessage to a desired Java type. |
com.google.pubsub.v1.PubsubMessage |
toPubSubMessage(Object payload,
Map<String,String> headers)
Create a
PubsubMessage given an object for the payload and a map of headers. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
byteStringToPubSubMessage
public SimplePubSubMessageConverter()
public SimplePubSubMessageConverter(Charset charset)
public com.google.pubsub.v1.PubsubMessage toPubSubMessage(Object payload, Map<String,String> headers)
PubSubMessageConverter
PubsubMessage
given an object for the payload and a map of headers.toPubSubMessage
in interface PubSubMessageConverter
payload
- the object to place into the message payloadheaders
- the headers of the messagepublic <T> T fromPubSubMessage(com.google.pubsub.v1.PubsubMessage message, Class<T> payloadType)
PubSubMessageConverter
PubsubMessage
to a desired Java type.fromPubSubMessage
in interface PubSubMessageConverter
T
- the type of the payloadmessage
- the message containing the payload of the objectpayloadType
- the desired type of the objectCopyright © 2021. All rights reserved.