Interface MessageConverter

  • All Superinterfaces:
    javax.enterprise.inject.spi.Prioritized
    All Known Implementing Classes:
    ConsumerRecordConverter, MessageConverter.IdentityConverter, RecordConverter

    @Experimental("SmallRye only feature")
    public interface MessageConverter
    extends javax.enterprise.inject.spi.Prioritized
    Converter transforming Message<A> into Message<B>. To register a converter, expose a, generally ApplicationScoped bean, implementing this interface.

    When multiple converters are available, implementation should override the getPriority() method. The default priority is CONVERTER_DEFAULT_PRIORITY. Converters with higher priority are executed first.

    • Field Detail

      • CONVERTER_DEFAULT_PRIORITY

        static final int CONVERTER_DEFAULT_PRIORITY
        Default priority: 100
        See Also:
        Constant Field Values
    • Method Detail

      • canConvert

        boolean canConvert​(Message<?> in,
                           Type target)
        Checks whether this instance of converter can convert the given message in into a Message<T> with T being the type represented by target. When reactive messaging looks for a converter, it picks the first converter returning true for a given message.
        Parameters:
        in - the input message, not null
        target - the target type, generally the type ingested by a method
        Returns:
        true if the conversion is possible, false otherwise.
      • convert

        Message<?> convert​(Message<?> in,
                           Type target)
        Converts the given message in into a Message<T>. This method is only called after a successful call to canConvert(Message, Type) with the given target type.
        Parameters:
        in - the input message
        target - the target type
        Returns:
        the converted message.
      • getPriority

        default int getPriority()
        Specified by:
        getPriority in interface javax.enterprise.inject.spi.Prioritized