Class JacksonPubSubMessageConverter
java.lang.Object
com.google.cloud.spring.pubsub.support.converter.JacksonPubSubMessageConverter
- All Implemented Interfaces:
PubSubMessageConverter
A converter using Jackson JSON.
-
Constructor Summary
ConstructorDescriptionJacksonPubSubMessageConverter
(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Constructor. -
Method Summary
Modifier and TypeMethodDescription<T> T
fromPubSubMessage
(com.google.pubsub.v1.PubsubMessage message, Class<T> payloadType) Convert the payload of a givenPubsubMessage
to a desired Java type.com.google.pubsub.v1.PubsubMessage
toPubSubMessage
(Object payload, Map<String, String> headers) Create aPubsubMessage
given an object for the payload and a map of headers.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.google.cloud.spring.pubsub.support.converter.PubSubMessageConverter
byteStringToPubSubMessage
-
Constructor Details
-
JacksonPubSubMessageConverter
public JacksonPubSubMessageConverter(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Constructor.- Parameters:
objectMapper
- the object mapper used to create and read JSON.
-
-
Method Details
-
toPubSubMessage
public com.google.pubsub.v1.PubsubMessage toPubSubMessage(Object payload, Map<String, String> headers) Description copied from interface:PubSubMessageConverter
Create aPubsubMessage
given an object for the payload and a map of headers.- Specified by:
toPubSubMessage
in interfacePubSubMessageConverter
- Parameters:
payload
- the object to place into the message payloadheaders
- the headers of the message- Returns:
- the PubsubMessage ready to be sent
-
fromPubSubMessage
Description copied from interface:PubSubMessageConverter
Convert the payload of a givenPubsubMessage
to a desired Java type.- Specified by:
fromPubSubMessage
in interfacePubSubMessageConverter
- Type Parameters:
T
- the type of the payload- Parameters:
message
- the message containing the payload of the objectpayloadType
- the desired type of the object- Returns:
- the object converted from the message's payload
-