public class ConvertingBytesMessageMapper extends Object implements BytesMessageMapper
BytesMessageMapper
implementation to delegate to/from Message
conversion into the provided MessageConverter
.
The MessageConverter
must not return null
from its
MessageConverter.fromMessage(Message, Class)
and MessageConverter.toMessage(Object, MessageHeaders)
methods.
If MessageConverter.fromMessage(Message, Class)
returns String
, it is converted to byte[]
using a StandardCharsets.UTF_8
encoding.
Constructor and Description |
---|
ConvertingBytesMessageMapper(MessageConverter messageConverter) |
Modifier and Type | Method and Description |
---|---|
byte[] |
fromMessage(Message<?> message) |
Message<?> |
toMessage(byte[] bytes,
Map<String,Object> headers)
Convert a provided object to the
Message
and supply with headers if necessary and provided. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
toMessage
public ConvertingBytesMessageMapper(MessageConverter messageConverter)
@NonNull public Message<?> toMessage(byte[] bytes, @Nullable Map<String,Object> headers)
InboundMessageMapper
Message
and supply with headers if necessary and provided.toMessage
in interface BytesMessageMapper
toMessage
in interface InboundMessageMapper<byte[]>
bytes
- the object for message payload or some other conversion logicheaders
- additional headers for building message. Can be null@NonNull public byte[] fromMessage(Message<?> message)
fromMessage
in interface OutboundMessageMapper<byte[]>