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[]>
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
FieldsModifier and TypeFieldDescriptionstatic final ByteArrayRawSerializerA 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
ConstructorsConstructorDescriptionByteArrayRawSerializer(boolean treatTimeoutAsEndOfMessage) Treat socket timeouts as a normal EOF and emit the (possibly partial) message. -
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]doDeserialize(InputStream inputStream, byte[] buffer) voidserialize(byte[] bytes, OutputStream outputStream) Methods inherited from class org.springframework.integration.ip.tcp.serializer.AbstractPooledBufferByteArraySerializer
copyToSizedArray, deserialize, setPoolSize, setPoolWaitTimeoutMethods inherited from class org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer
checkClosure, getMaxMessageSize, publishEvent, setApplicationEventPublisher, setMaxMessageSizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.core.serializer.Deserializer
deserializeFromByteArrayMethods 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:
doDeserializein classAbstractPooledBufferByteArraySerializer- Parameters:
inputStream- the input stream.buffer- the raw working buffer (maxMessageSize).- Returns:
- the decoded bytes.
- Throws:
IOException- an io exception.
-