Class AmqpMessageConverter

java.lang.Object
es.kukenan.smartfi.amqp.config.AmqpMessageConverter
All Implemented Interfaces:
org.springframework.amqp.support.converter.MessageConverter

public class AmqpMessageConverter extends Object implements org.springframework.amqp.support.converter.MessageConverter
Amqp message converter for the request queue.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final AmqpFilter
    A filter which only function is propagate request contest (requestId and companyId).
    private final es.kukenan.smartfi.common.utils.CustomObjectMapper
    Jackson object mapper to read/write json.
    private final es.kukenan.smartfi.events.common.spring.EventParserManager
    smartfi business event managers.
  • Constructor Summary

    Constructors
    Constructor
    Description
    AmqpMessageConverter(es.kukenan.smartfi.events.common.spring.EventParserManager eventParserManager, AmqpFilter contextPropagationFilter, es.kukenan.smartfi.common.utils.CustomObjectMapper customObjectMapper)
    State constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    private String
    charset(byte[] message)
     
    fromMessage(org.springframework.amqp.core.Message message)
     
    private com.fasterxml.jackson.databind.JsonNode
    Converts bytes to a JsonNode trying to detect string encoding first.
    private com.fasterxml.jackson.databind.JsonNode
    jsonMessageContent(org.springframework.amqp.core.Message message)
    Converts message content to a JsonNode.
    org.springframework.amqp.core.Message
    toMessage(Object object, org.springframework.amqp.core.MessageProperties messageProperties)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.amqp.support.converter.MessageConverter

    toMessage
  • Field Details

    • contextPropagationFilter

      private final AmqpFilter contextPropagationFilter
      A filter which only function is propagate request contest (requestId and companyId).
    • customObjectMapper

      private final es.kukenan.smartfi.common.utils.CustomObjectMapper customObjectMapper
      Jackson object mapper to read/write json.
    • eventParserManager

      private final es.kukenan.smartfi.events.common.spring.EventParserManager eventParserManager
      smartfi business event managers.
  • Constructor Details

    • AmqpMessageConverter

      public AmqpMessageConverter(es.kukenan.smartfi.events.common.spring.EventParserManager eventParserManager, AmqpFilter contextPropagationFilter, es.kukenan.smartfi.common.utils.CustomObjectMapper customObjectMapper)
      State constructor.
      Parameters:
      eventParserManager - eventParserManager.
      contextPropagationFilter - contextPropagationFilter.
      customObjectMapper - customObjectMapper.
  • Method Details

    • toMessage

      public org.springframework.amqp.core.Message toMessage(Object object, org.springframework.amqp.core.MessageProperties messageProperties) throws org.springframework.amqp.support.converter.MessageConversionException
      Specified by:
      toMessage in interface org.springframework.amqp.support.converter.MessageConverter
      Throws:
      org.springframework.amqp.support.converter.MessageConversionException
    • fromMessage

      public Object fromMessage(org.springframework.amqp.core.Message message) throws org.springframework.amqp.support.converter.MessageConversionException
      Specified by:
      fromMessage in interface org.springframework.amqp.support.converter.MessageConverter
      Throws:
      org.springframework.amqp.support.converter.MessageConversionException
    • jsonMessageContent

      private com.fasterxml.jackson.databind.JsonNode jsonMessageContent(org.springframework.amqp.core.Message message) throws org.springframework.amqp.support.converter.MessageConversionException
      Converts message content to a JsonNode. If it is not possible, then throws a MessageConversionException.
      Parameters:
      message - the message which content is to be converted.
      Returns:
      the JsonNode produced by content parsing.
      Throws:
      org.springframework.amqp.support.converter.MessageConversionException - if the content is ot a valid JSON.
    • jsonFromBytesWithEncodingDetection

      private com.fasterxml.jackson.databind.JsonNode jsonFromBytesWithEncodingDetection(byte[] message) throws org.springframework.amqp.support.converter.MessageConversionException
      Converts bytes to a JsonNode trying to detect string encoding first. If it is not possible, then throws a MessageConversionException.
      Parameters:
      message - the message which content is to be converted.
      Returns:
      the JsonNode produced by content parsing.
      Throws:
      org.springframework.amqp.support.converter.MessageConversionException - if the content is ot a valid JSON.
    • charset

      private String charset(byte[] message) throws IOException
      Throws:
      IOException