Interface MessageConverter

All Known Implementing Classes:
Jackson2MessageConverter, Jackson3MessageConverter, StringMessageConverter

public interface MessageConverter

Converts messages between String representation and target object types.

Implementations must be thread-safe, and it is recommended that they are stateless.

Since:
1.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the content type associated with this message converter.
    Converts the given object to its String representation.
    <T> T
    convertToType(String messageStr, Class<T> targetType)
    Converts the given message string to the specified target type.
  • Method Details

    • convertToType

      <T> T convertToType(String messageStr, Class<T> targetType) throws ConversionException
      Converts the given message string to the specified target type.
      Type Parameters:
      T - the target type
      Parameters:
      messageStr - the message in String format
      targetType - the desired target type class
      Returns:
      the converted message object of the specified target type
      Throws:
      ConversionException - if the conversion fails
      Since:
      1.0.0
    • convertToString

      String convertToString(Object object)

      Converts the given object to its String representation.

      The string must be UTF-8 encoded.

      Parameters:
      object - the object to convert
      Returns:
      the String representation of the object
      Since:
      1.0.0
    • contentType

      String contentType()

      Returns the content type associated with this message converter. This content type is used in STOMP message headers to indicate the format of the message body.

      This is typically a MIME type, such as text/plain;charset=UTF-8 or application/json;charset=UTF-8.

      Returns:
      the content type as a String
      Since:
      1.0.0