Class SimplePubSubMessageConverter

All Implemented Interfaces:

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 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
      payload - the object to place into the message payload
      headers - the headers of the message
      the PubsubMessage ready to be sent
    • fromPubSubMessage

      public <T> T fromPubSubMessage( 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
      message - the message containing the payload of the object
      payloadType - the desired type of the object
      the object converted from the message's payload