Nuno Carvalho wrote:
In fact the optimization you talk about is contemplated in the
org.continuent.hedera.channel.ChannelMessage class. You should be able
to inherit from this class and override the getByteArray method. Any
message-specific optimizations can be implemented there.
Then it's up to the particular Hedera implementation to invoke
getByteArray rather than using plain Java serialization. You can see
an example in the send method of the
org.continuent.hedera.channel.JGroupsReliableGroupChannel class.
Yes, in fact Hedera already has a solution for this. But in the
ChannelMessage, only half of the solution is solved. The user can
override the getByteArray method to serialize the list of chunks, but
must implement the inverted operation, that takes a byte[] and rebuilds
the list of chunks, outside ChannelMessage (in the receive method of the
hedera ReliableGroupChannel).
My suggestion is that the ChannelMessage should already have the 2
operations: the getByteArray() and something like getChunks(byte[] msg)
that makes the inverted operation. Off course, if the programmer extends
the ChannelMessage, could make this option, but shouldn't this be
already on the API of the message it self?
Regards,
Nuno Carvalho
True, we could have a static factory method: createFromByteArray(byte[]
rawdata). Its default implementation would be something like:
public static ChannelMessage createFromByteArray(byte[] rawdata) {
return (ChannelMessage) new ObjectInputStream(
new ByteArrayInputStream(rawdata)).readObject();
}
That method should be overridden together with getByteArray() to provide
a "smart" serialization mechanism.
I keep that one on the side and will try to batch it with other
suggestions as soon as I have more time to dedicate to Hedera.
By the way, it would make sense to host the source code for the Hedera
Wrapper for Appia on the continuent.org forge. Exposing such wrapping
code to the community would help to better understand the kind of API
issues we are discussing here.
Cheers,
Damián
_______________________________________________
Hedera mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/hedera