Class AutoConvertMessageTranslator

  • All Implemented Interfaces:
    AdaptrisMessageTranslator, ComponentLifecycle, MessageTypeTranslator, MetadataHandlerContext

    public class AutoConvertMessageTranslator
    extends MessageTypeTranslatorImp
    Perform a best guess routine on the JMSMessage when translating to an AdaptrisMessage.

    This handles the types TextMessage, BytesMessage, ObjectMessage by delegating to the correct MessageTypeTranslator implementation. The mapping from MapMessage to AdaptrisMessage is simplistic; the name value pairs (assumed to be String (or convertable to String)) are set as AdaptrisMessage metadata, the resulting payload is empty. The mapping from AdaptrisMessage to MapMessage results in all metadata being mapped as name value pairs in the MapMessage; the payload is ignored.

    If you have used this translator for your consumer we add a new meta-data item to the AdaptrisMessage} named "adpmessagetype". The value of this item will be one of "Text", "Bytes", "Map" or "Object". This allows you to set the following item; "convert-back-to-consumed-type" on the AutoConvertMessageTranslator for your JMS producer to "true" (default is false). In this case this translator will attempt to translate the produced message to the same message type we consumed.

    By default the metadata item "adpmessagetype" is removed before we convert the Adaptris message to a JMS message, so that the JMS message does not contain the key. You can override the removal of the key should you have multiple producers, by setting remove-original-message-type-key to "true".

    If this converter cannot find an appropriate translator then a very basic translation will be applied. This will NOT include any payload translation. You will also see a warning in the logs to notify you a basic translation has been applied.

    It is primarily a fallback translator to mitigate configuration errors.

    In the adapter configuration file this class is aliased as auto-convert-message-translator which is the preferred alternative to the fully qualified classname when building your configuration.

    • Constructor Detail

      • AutoConvertMessageTranslator

        public AutoConvertMessageTranslator()
        Default constructor.

        • jms-output-type is "Text"
    • Method Detail

      • translate

        public javax.jms.Message translate​(AdaptrisMessage msg)
                                    throws javax.jms.JMSException
        Description copied from interface: MessageTypeTranslator

        Translates the passed AdaptrisMessage into an instance of a subclass of javax.jms.Message.

        Parameters:
        msg - the AdaptrisMessage to translate
        Returns:
        a javax.jms.Message
        Throws:
        javax.jms.JMSException
      • translate

        public AdaptrisMessage translate​(javax.jms.Message msg)
                                  throws javax.jms.JMSException
        Description copied from interface: MessageTypeTranslator

        Translates the passed javax.jms.Message into an instance of AdaptrisMessage.

        Parameters:
        msg - the javax.jms.Message to translate
        Returns:
        a AdaptrisMessage
        Throws:
        javax.jms.JMSException
      • getJmsOutputType

        public java.lang.String getJmsOutputType()
      • setJmsOutputType

        public void setJmsOutputType​(java.lang.String outputType)
        Set the javax.jms.Message implementation that this MessageTranslator creates when converting from AdaptrisMessage.
        Parameters:
        outputType - the output type, one of Object, Text, Bytes, Map
        See Also:
        AutoConvertMessageTranslator.SupportedMessageType
      • getConvertBackToConsumedType

        public java.lang.Boolean getConvertBackToConsumedType()
      • setConvertBackToConsumedType

        public void setConvertBackToConsumedType​(java.lang.Boolean convertBackToConsumedType)
      • getRemoveOriginalMessageTypeKey

        public java.lang.Boolean getRemoveOriginalMessageTypeKey()
      • setRemoveOriginalMessageTypeKey

        public void setRemoveOriginalMessageTypeKey​(java.lang.Boolean removeOriginalMessageTypeKey)