Package io.smallrye.reactive.messaging
Interface MessageConverter
-
- All Superinterfaces:
javax.enterprise.inject.spi.Prioritized
- All Known Implementing Classes:
ConsumerRecordConverter
,ConsumerRecordsConverter
,MessageConverter.IdentityConverter
,RecordConverter
@Experimental("SmallRye only feature") public interface MessageConverter extends javax.enterprise.inject.spi.Prioritized
Converter transformingMessage<A>
intoMessage<B>
. To register a converter, expose a, generallyApplicationScoped
bean, implementing this interface.When multiple converters are available, implementation should override the
getPriority()
method. The default priority isCONVERTER_DEFAULT_PRIORITY
. Converters with higher priority are executed first.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
MessageConverter.IdentityConverter
-
Field Summary
Fields Modifier and Type Field Description static int
CONVERTER_DEFAULT_PRIORITY
Default priority:100
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
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<?>
convert(Message<?> in, Type target)
Converts the given messagein
into aMessage<T>
.default int
getPriority()
-
-
-
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 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
Message<?> convert(Message<?> in, Type target)
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 interfacejavax.enterprise.inject.spi.Prioritized
-
-