Interface MessageConverter

  • All Superinterfaces:
    jakarta.enterprise.inject.spi.Prioritized
    All Known Implementing Classes:
    MessageConverter.IdentityConverter

    @Experimental("SmallRye only feature")
    public interface MessageConverter
    extends jakarta.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. Converters with higher priority (lesser value) are executed first. The default priority is CONVERTER_DEFAULT_PRIORITY.

    • 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 jakarta.enterprise.inject.spi.Prioritized