Package io.smallrye.reactive.messaging
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.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault priority:100 -
Method Summary
Modifier and TypeMethodDescriptionbooleancanConvert(Message<?> in, Type target) Checks whether this instance of converter can convert the given messageininto aMessage<T>withTbeing the type represented bytarget.Message<?> Converts the given messageininto aMessage<T>.default int
-
Field Details
-
CONVERTER_DEFAULT_PRIORITY
static final int CONVERTER_DEFAULT_PRIORITYDefault priority:100- See Also:
-
-
Method Details
-
canConvert
Checks whether this instance of converter can convert the given messageininto aMessage<T>withTbeing the type represented bytarget. When reactive messaging looks for a converter, it picks the first converter returningtruefor a given message.- Parameters:
in- the input message, notnulltarget- the target type, generally the type ingested by a method- Returns:
trueif the conversion is possible,falseotherwise.
-
convert
Converts the given messageininto aMessage<T>. This method is only called after a successful call tocanConvert(Message, Type)with the given target type.- Parameters:
in- the input messagetarget- the target type- Returns:
- the converted message.
-
getPriority
default int getPriority()- Specified by:
getPriorityin interfacejakarta.enterprise.inject.spi.Prioritized
-