Class SimplePubSubMessageConverter

java.lang.Object
com.google.cloud.spring.pubsub.support.converter.SimplePubSubMessageConverter
All Implemented Interfaces:
PubSubMessageConverter

public class SimplePubSubMessageConverter extends Object implements PubSubMessageConverter
A simple PubSubMessageConverter that directly maps payloads of type byte[], ByteString, ByteBuffer, and String to Pub/Sub messages.
  • Constructor Details

    • SimplePubSubMessageConverter

      public SimplePubSubMessageConverter()
    • SimplePubSubMessageConverter

      public SimplePubSubMessageConverter(Charset charset)
  • Method Details

    • toPubSubMessage

      public com.google.pubsub.v1.PubsubMessage toPubSubMessage(Object payload, Map<String,String> headers)
      Description copied from interface: PubSubMessageConverter
      Create a PubsubMessage given an object for the payload and a map of headers.
      Specified by:
      toPubSubMessage in interface PubSubMessageConverter
      Parameters:
      payload - the object to place into the message payload
      headers - the headers of the message
      Returns:
      the PubsubMessage ready to be sent
    • fromPubSubMessage

      public <T> T fromPubSubMessage(com.google.pubsub.v1.PubsubMessage message, Class<T> payloadType)
      Description copied from interface: PubSubMessageConverter
      Convert the payload of a given PubsubMessage to a desired Java type.
      Specified by:
      fromPubSubMessage in interface PubSubMessageConverter
      Type Parameters:
      T - the type of the payload
      Parameters:
      message - the message containing the payload of the object
      payloadType - the desired type of the object
      Returns:
      the object converted from the message's payload