Class JsonRabbitMessageSerDes

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

    @Singleton
    public class JsonRabbitMessageSerDes
    extends java.lang.Object
    implements RabbitMessageSerDes<java.lang.Object>
    Serializes and deserializes objects as JSON using Jackson.
    Since:
    1.1.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.Integer ORDER
      The order of this serDes.
      • Fields inherited from interface io.micronaut.core.order.Ordered

        HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object deserialize​(RabbitConsumerState messageState, io.micronaut.core.type.Argument<java.lang.Object> type)
      Deserializes the message into the requested type.
      int getOrder()  
      byte[] serialize​(java.lang.Object data, MutableBasicProperties basicProperties)
      Serializes the data into a byte[] to be published to RabbitMQ.
      boolean supports​(io.micronaut.core.type.Argument<java.lang.Object> argument)
      Determines if this serdes supports the given type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ORDER

        public static final java.lang.Integer ORDER
        The order of this serDes.
    • Constructor Detail

      • JsonRabbitMessageSerDes

        @Deprecated
        public JsonRabbitMessageSerDes​(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
        Deprecated.
        Legacy jackson constructor.
        Parameters:
        objectMapper - The jackson object mapper
      • JsonRabbitMessageSerDes

        @Inject
        public JsonRabbitMessageSerDes​(io.micronaut.json.JsonMapper jsonMapper)
        Default constructor.
        Parameters:
        jsonMapper - The json mapper
        Since:
        3.2.0
    • Method Detail

      • deserialize

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

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

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

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