How to avoid buffer copies when sending¶
Problem¶
You require absolute maximum performance, and have messages that are guaranteed to be smaller than maxPayloadLength.
Solution¶
Use Publication.tryClaim instead of Publication.offer.
Sample¶
Construct a BufferClaim, retrieve it from the publication.tryClaim and write to it:
1 2 3 4 5 | |
Discussion¶
TryClaim allows you to take ownership of a portion of a given length of the active term in the Aeron log buffer. Once you have a valid buffer claim (as detected by the result being > 0), you are able to putBytes or wrap your data.
You must commit() or abort() before the unblock timeout (default 15 seconds) occurs.