Here is the client:
Here is the server:
The purpose was to use Netty server with a not-Netty client to receive the objects. But it didn’t work and here’s why:
A decoder which deserializes the received ByteBufs into Java objects.
Please note that the serialized form this decoder expects is not compatible with the standard ObjectOutputStream. Please use ObjectEncoder or ObjectEncoderOutputStream to ensure the interoperability with this decoder.
Here’s the updated version of the client which works with ObjectDecoder:
And the output from the server:
It works but it is not what I was looking for. What if we don’t have an access to the client’s code and can’t modify it to meet the Netty’s server requirements for encoding/decoding java objects. For example, log4j’s SocketAppender where the client is a log4j system which sends LoggingEvent objects via socket to all listening servers.
I found out that in Netty 3.x version there was a class which could solve my problem: CompatibleObjectDecoder. But it was deprecated and removed in 4.x version (which I use now). That was because of this critical bug: Deprecate CompatibleObjectDecoder.
Now it seems that Netty is incompatible with Java’s ObjectOutputStream/ObjectInputStream at all.