Class JavaLangRabbitMessageSerDes

java.lang.Object
io.micronaut.rabbitmq.serdes.JavaLangRabbitMessageSerDes
All Implemented Interfaces:
io.micronaut.core.order.Ordered, RabbitMessageSerDes<Object>

@Singleton public class JavaLangRabbitMessageSerDes extends Object implements RabbitMessageSerDes<Object>
Serializes and deserializes standard Java types.
Since:
1.1.0
Author:
James Kleeh
  • Field Details

  • Constructor Details

    • JavaLangRabbitMessageSerDes

      public JavaLangRabbitMessageSerDes()
      Default constructor.
  • Method Details

    • serialize

      public byte[] serialize(@Nullable @Nullable Object data, MutableBasicProperties properties)
      Description copied from interface: RabbitMessageSerDes
      Serializes the data into a byte[] to be published to RabbitMQ.
      Specified by:
      serialize in interface RabbitMessageSerDes<Object>
      Parameters:
      data - The data to serialize
      properties - The properties of the message
      Returns:
      The message body
    • deserialize

      public Object deserialize(RabbitConsumerState messageState, io.micronaut.core.type.Argument<Object> argument)
      Description copied from interface: RabbitMessageSerDes
      Deserializes the message into the requested type.
      Specified by:
      deserialize in interface RabbitMessageSerDes<Object>
      Parameters:
      messageState - The message to deserialize
      argument - The type to be returned
      Returns:
      The deserialized body
    • supports

      public boolean supports(io.micronaut.core.type.Argument<Object> argument)
      Description copied from interface: RabbitMessageSerDes
      Determines if this serdes supports the given type.
      Specified by:
      supports in interface RabbitMessageSerDes<Object>
      Parameters:
      argument - The type
      Returns:
      True if the type is supported
    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface io.micronaut.core.order.Ordered
    • findSerDes

      @Nullable protected @Nullable RabbitMessageSerDes findSerDes(io.micronaut.core.type.Argument<?> type)
      Finds the correct serDes based on the type.
      Parameters:
      type - The java type
      Returns:
      The serdes, or null if none can be found
    • getStringSerDes

      @NonNull protected @NonNull RabbitMessageSerDes<String> getStringSerDes()
      Returns:
      The serDes that handles String
    • getShortSerDes

      @NonNull protected @NonNull RabbitMessageSerDes<Short> getShortSerDes()
      Returns:
      The serDes that handles Short
    • getIntegerSerDes

      @NonNull protected @NonNull RabbitMessageSerDes<Integer> getIntegerSerDes()
      Returns:
      The serDes that handles Integer
    • getLongSerDes

      @NonNull protected @NonNull RabbitMessageSerDes<Long> getLongSerDes()
      Returns:
      The serDes that handles Long
    • getFloatSerDes

      @NonNull protected @NonNull RabbitMessageSerDes<Float> getFloatSerDes()
      Returns:
      The serDes that handles Float
    • getDoubleSerDes

      @NonNull protected @NonNull RabbitMessageSerDes<Double> getDoubleSerDes()
      Returns:
      The serDes that handles Double
    • getByteArraySerDes

      @NonNull protected @NonNull RabbitMessageSerDes<byte[]> getByteArraySerDes()
      Returns:
      The serDes that handles byte[]
    • getByteBufferSerDes

      @NonNull protected @NonNull RabbitMessageSerDes<ByteBuffer> getByteBufferSerDes()
      Returns:
      The serDes that handles ByteBuffer
    • getUUIDSerDes

      @NonNull protected @NonNull RabbitMessageSerDes<UUID> getUUIDSerDes()
      Returns:
      The serDes that handles UUID
    • getBooleanSerDes

      @NonNull protected @NonNull RabbitMessageSerDes<Boolean> getBooleanSerDes()
      Returns:
      The serDes that handles UUID