I am considering message serialization support for spring-integration . This would be useful for various conductors at the conductor level to implement guaranteed delivery , but also to ensure compatibility with other messaging systems (for example, via AMQP).
The main problem that arises is that a message containing a Java object in its payload and headers must be converted to byte[]and / or written to the stream. Java serialization itself is clearly not going to abbreviate it because it is not compatible. My preference would be to create an interface that allows the user to implement the necessary logic for all objects that participate in serialization.
This means that I do not want the client developer to generate their domain code, but rather define a serializer for the objects that need it. The interfaces will be something like this:
public interface PayloadSerializer<T> {
byte[] bytesForObject(T source);
T objectFromBytes(byte[]);
}
Is this a smart idea and what would the perfect interface look like? Is there a standard way to interact with objects that makes sense in this context?