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
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Default priority:100
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canConvert
(Message<?> in, Type target) Checks whether this instance of converter can convert the given messagein
into aMessage<T>
withT
being the type represented bytarget
.Message<?>
Converts the given messagein
into 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 messagein
into aMessage<T>
withT
being the type represented bytarget
. When reactive messaging looks for a converter, it picks the first converter returningtrue
for a given message.- Parameters:
in
- the input message, notnull
target
- the target type, generally the type ingested by a method- Returns:
true
if the conversion is possible,false
otherwise.
-
convert
Converts the given messagein
into 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:
getPriority
in interfacejakarta.enterprise.inject.spi.Prioritized
-