Class AbstractSimpleCodec

    • Constructor Detail

      • AbstractSimpleCodec

        public AbstractSimpleCodec​(org.slf4j.Logger logger,
                                   PluginConstructorParameters.CodecConstructorParameters params)
                            throws java.lang.IllegalArgumentException,
                                   java.lang.Exception
        Constructor. A subclass should provide its own constructor with the same signature as this one. This base class makes the parameters passed into its constructor available as member fields or methods for use by the subclass.
        Parameters:
        logger - a slf4j Logger object which can be used to log to the host log file.
        params - an extensible interface providing access to the configuration for this plug-in and other capabilities.
        Throws:
        java.lang.IllegalArgumentException - should be thrown from a plug-in's constructor if the configuration is invalid.
        java.lang.Exception - can be thrown to indicate an internal error.
        Since:
        9.12.0.1
    • Method Detail

      • transformMessageTowardsHost

        public abstract Message transformMessageTowardsHost​(Message message)
                                                     throws java.lang.Exception
        Transform an individual message with a non-null payload. Decode an individual message, optionally producing a result. If this method throws then the exception will be logged and the message dropped.
        Parameters:
        message - - the message, guaranteed to be non-null and have a non-null payload.
        Returns:
        the decoded message, or null if it is to be discarded.
        Throws:
        java.lang.Exception
        See Also:
        transformNullPayloadTowardsHost(Message)
      • transformMessageTowardsTransport

        public abstract Message transformMessageTowardsTransport​(Message message)
                                                          throws java.lang.Exception
        Transform an individual message with a non-null payload. Encode an individual message, optionally producing a result. If this method throws then the exception will be logged and the message dropped.
        Parameters:
        message - - the message, guaranteed to be non-null and have a non-null payload.
        Returns:
        the encoded message, or null if it is to be discarded.
        Throws:
        java.lang.Exception
        See Also:
        transformNullPayloadTowardsTransport(Message)
      • transformNullPayloadTowardsHost

        public Message transformNullPayloadTowardsHost​(Message message)
                                                throws java.lang.Exception
        Transform an individual message that has a null payload.

        By convention, most plug-ins silently pass through messages with null payloads without transforming them. Thus, the default implementation of this method is to just return the value passed in. If this method throws then the exception will be logged and the message dropped.

        Throws:
        java.lang.Exception
      • transformNullPayloadTowardsTransport

        public Message transformNullPayloadTowardsTransport​(Message message)
                                                     throws java.lang.Exception
        Transform an individual message that has a null payload.

        By convention, most plug-ins silently pass through messages with null payloads without transforming them. Thus, the default implementation of this method is to just return the value passed in. If this method throws then the exception will be logged and the message dropped.

        Throws:
        java.lang.Exception
      • handleException

        public Message handleException​(java.lang.Exception ex,
                                       Message message,
                                       boolean towardsTransport)
        Handle an exception thrown from transforming messages.

        The default implementation is to log an error and return null (thus discarding this message, but not others in the same batch)

        Parameters:
        e - T