Open plokhotnyuk opened 5 years ago
For send/receive scenario I can suggest looking into SendReceive example where you can feed Receiver with byte[] data and get corresponding handlers called:
public class Receiver
{
...
public void receive(byte[] buffer);
public void receive(byte[] buffer, long offset, long size);
...
// Receive handlers
protected void onReceive(proto.Order value) {}
protected void onReceive(proto.Balance value) {}
protected void onReceive(proto.Account value) {}
}
Java benchmarks use byte[] based dynamic buffer to serrialize/deserialize objects.
Also this Buffer has methods to attach any byte[] data to serrialize/deserialize objects:
public class Buffer
{
...
public void attach(byte[] buffer) { _data = buffer; _size = buffer.length; _offset = 0; }
public void attach(byte[] buffer, long offset) { _data = buffer; _size = buffer.length; _offset = offset; }
public void attach(byte[] buffer, long size, long offset) { _data = buffer; _size = size; _offset = offset; }
...
}
Currently benchmarks test only half of the real use case, because usually we receive/send buffered bytes from the wire or disks, not strings.