Good morning,
I am trying to understand the low lattency library aeron, I have an instance of the class Publication:
Publication publication=new Publication(CHANNEL, STREAM_ID);
Where:
CHANNEL=System.getProperty("aeron.sample.channel", "aeron:udp?endpoint=224.0.1.1:40456");
and
STREAM_ID=Integer.getInteger("aeron.sample.streamId", 10);
After creating the instance, to send a message what it does is:
String a="What I want to send"; //Text that I want to send
bytes[] aBytes=a.getBytes(); // Convert the string to an array of bytes
UnsafeBuffer BUFFER = new UnsafeBuffer(BufferUtil.allocateDirectAligned(256, 64)); //Create an UnsafeBuffer (https://github.com/real-logic/agrona/blob/master/agrona/src/main/java/org/agrona/concurrent/UnsafeBuffer.java)
BUFFER.putBytes(0, aBytes); //Put the Bytes of the array of bytes that contains the text intro tje BUFFER
final long result = publication.offer(BUFFER, 0, messageBytes.length); //This is the last line of the code to send the message, so I guess that this line is used to send the message to the mediaDriver.
I want to understand how the last line of code works, Method offer() is at the following file: https://github.com/real-logic/aeron/blob/master/aeron-client/src/main/java/io/aeron/Publication.java
At line 373 There is the following method:
public final long offer(final DirectBuffer buffer, final int offset, final int length)
{
return offer(buffer, offset, length, null);
}
That returns a function, If I search for this function in the Publication.java file I only found the following:
public abstract long offer(DirectBuffer buffer, int offset, int length, ReservedValueSupplier reservedValueSupplier);
It's an abstract method that I don't know where I could found the definition of it.
If someone could help me I will appreciate a lot to understand how this library works.
I bet you have found all answers but in case for future searchers:
There are 2 implementation of Publication class :
I can recomend to watch Martin's video about how Aeron works https://www.youtube.com/watch?v=tM4YskS94b0