public class TcpMessageMapper extends java.lang.Object implements InboundMessageMapper<TcpConnection>, OutboundMessageMapper<java.lang.Object>
TcpConnection
to a Message
.
If StringToBytes is true (default),
payloads of type String are converted to a byte[] using the supplied
charset (UTF-8 by default).
Inbound messages include headers representing the remote end of the
connection as well as a connection id that can be used by a TcpSender
to correlate which connection to send a reply. If applySequence is set, adds
standard correlationId/sequenceNumber headers allowing for downstream (unbounded)
resequencing.Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
logger |
Constructor and Description |
---|
TcpMessageMapper() |
Modifier and Type | Method and Description |
---|---|
protected void |
addCustomHeaders(TcpConnection connection,
MessageBuilder<?> messageBuilder) |
protected void |
addStandardHeaders(TcpConnection connection,
MessageBuilder<?> messageBuilder) |
java.lang.Object |
fromMessage(Message<?> message) |
void |
setApplySequence(boolean applySequence) |
void |
setCharset(java.lang.String charset) |
void |
setStringToBytes(boolean stringToBytes)
Sets whether outbound String payloads are to be converted
to byte[].
|
protected java.util.Map<java.lang.String,?> |
supplyCustomHeaders(TcpConnection connection)
Override to provide additional headers.
|
Message<java.lang.Object> |
toMessage(TcpConnection connection) |
public Message<java.lang.Object> toMessage(TcpConnection connection) throws java.lang.Exception
toMessage
in interface InboundMessageMapper<TcpConnection>
java.lang.Exception
protected final void addStandardHeaders(TcpConnection connection, MessageBuilder<?> messageBuilder)
protected final void addCustomHeaders(TcpConnection connection, MessageBuilder<?> messageBuilder)
protected java.util.Map<java.lang.String,?> supplyCustomHeaders(TcpConnection connection)
connection
- the connection.<String, ?>
headers to be added to the message.public java.lang.Object fromMessage(Message<?> message) throws java.lang.Exception
fromMessage
in interface OutboundMessageMapper<java.lang.Object>
java.lang.Exception
public void setCharset(java.lang.String charset)
charset
- the charset to setpublic void setStringToBytes(boolean stringToBytes)
stringToBytes
- public void setApplySequence(boolean applySequence)
applySequence
- the applySequence to set