Class ByteArrayRawSerializer
java.lang.Object
org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer
org.springframework.integration.ip.tcp.serializer.AbstractPooledBufferByteArraySerializer
org.springframework.integration.ip.tcp.serializer.ByteArrayRawSerializer
- All Implemented Interfaces:
Aware
,ApplicationEventPublisherAware
,Deserializer<byte[]>
,Serializer<byte[]>
public class ByteArrayRawSerializer extends AbstractPooledBufferByteArraySerializer
A byte array (de)serializer that does nothing with the payload; sends it raw.
Message termination for assembly purposes is signaled by the client closing the
connection. The serializer does not, itself, close the connection after
writing the bytes.
Because the socket must be closed to indicate message end, this (de)serializer can only be used by uni-directional (non-collaborating) channel adapters, and not by gateways.
Prior to 4.2.2, when using NIO, a timeout caused whatever had been partially received to be emitted as a message.
Now, a SocketTimeoutException
is thrown. To revert to the previous
behavior, set the treatTimeoutAsEndOfMessage
constructor argument to true.
- Since:
- 2.0.3
- Author:
- Gary Russell, Artem Bilan
-
Field Summary
Fields Modifier and Type Field Description static ByteArrayRawSerializer
INSTANCE
A single reusable instance that does not treat timeouts as end of message.Fields inherited from class org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer
DEFAULT_MAX_MESSAGE_SIZE, logger
-
Constructor Summary
Constructors Constructor Description ByteArrayRawSerializer()
ByteArrayRawSerializer(boolean treatTimeoutAsEndOfMessage)
Treat socket timeouts as a normal EOF and emit the (possibly partial) message. -
Method Summary
Modifier and Type Method Description protected byte[]
doDeserialize(InputStream inputStream, byte[] buffer)
void
serialize(byte[] bytes, OutputStream outputStream)
Methods inherited from class org.springframework.integration.ip.tcp.serializer.AbstractPooledBufferByteArraySerializer
copyToSizedArray, deserialize, setPoolSize, setPoolWaitTimeout
Methods inherited from class org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer
checkClosure, getMaxMessageSize, publishEvent, setApplicationEventPublisher, setMaxMessageSize
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.core.serializer.Deserializer
deserializeFromByteArray
Methods inherited from interface org.springframework.core.serializer.Serializer
serializeToByteArray
-
Field Details
-
INSTANCE
A single reusable instance that does not treat timeouts as end of message.
-
-
Constructor Details
-
ByteArrayRawSerializer
public ByteArrayRawSerializer() -
ByteArrayRawSerializer
public ByteArrayRawSerializer(boolean treatTimeoutAsEndOfMessage)Treat socket timeouts as a normal EOF and emit the (possibly partial) message.- Parameters:
treatTimeoutAsEndOfMessage
- true to emit a message after a timeout.- Since:
- 4.2.2
-
-
Method Details
-
serialize
- Throws:
IOException
-
doDeserialize
- Specified by:
doDeserialize
in classAbstractPooledBufferByteArraySerializer
- Parameters:
inputStream
- the input stream.buffer
- the raw working buffer (maxMessageSize).- Returns:
- the decoded bytes.
- Throws:
IOException
- an io exception.
-