aeron-client/src/main/java/io/aeron/ExclusivePublication.java
public long tryClaim(final int length, final BufferClaim bufferClaim)
    {
        checkPayloadLength(length);
        long newPosition = CLOSED;

        if (!isClosed)
        {
            final long limit = positionLimit.getVolatile();
            final ExclusiveTermAppender termAppender = termAppenders[activePartitionIndex];
            final long position = termBeginPosition + termOffset;

            if (position < limit)
            {
                final int result = termAppender.claim(termId, termOffset, headerWriter, length, bufferClaim);
                newPosition = newPosition(result);
            }
            else
            {
                newPosition = backPressureStatus(position, length);
            }
        }

        return newPosition;
    }
public long tryClaim(final int length, final BufferClaim bufferClaim)
    {
        checkPayloadLength(length);
        long newPosition = CLOSED;

        if (!isClosed)
        {
            final long limit = positionLimit.getVolatile();
            final ExclusiveTermAppender termAppender = termAppenders[activePartitionIndex];
            final long position = termBeginPosition + termOffset;

            if (position < limit)
            {
                final int result = termAppender.claim(termId, termOffset, headerWriter, length, bufferClaim);
                newPosition = newPosition(result);
            }
            else
            {
                newPosition = backPressureStatus(position, length);
            }
        }

        return newPosition;
    }
public long tryClaim ( final int length , final BufferClaim bufferClaim ) { checkPayloadLength ( length ) ; long newPosition = CLOSED ; if ( ! isClosed ) { final long limit = positionLimit . getVolatile ( ) ; final ExclusiveTermAppender termAppender = termAppenders [ activePartitionIndex ] ; final long position = termBeginPosition + termOffset ; if ( position < limit ) { final int result = termAppender . claim ( termId , termOffset , headerWriter , length , bufferClaim ) ; newPosition = newPosition ( result ) ; } else { newPosition = backPressureStatus ( position , length ) ; } } return newPosition ; }
Try to claim a range in the publication log into which a message can be written with zero copy semantics.
Once the message has been written then {@link BufferClaim#commit()} should be called thus making it
available.
<p>
<b>Note:</b> This method can only be used for message lengths less than MTU length minus header.
If the claim is held after the publication is closed, or the client dies, then it will be unblocked to reach
end-of-stream (EOS).
<pre>{@code
final BufferClaim bufferClaim = new BufferClaim();

if (publication.tryClaim(messageLength, bufferClaim) > 0L)
{
try
{
final MutableDirectBuffer buffer = bufferClaim.buffer();
final int offset = bufferClaim.offset();

// Work with buffer directly or wrap with a flyweight
}
finally
{
bufferClaim.commit();
}
}
}</pre>

@param length      of the range to claim, in bytes..
@param bufferClaim to be populated if the claim succeeds.
@return The new stream position, otherwise a negative error value of {@link #NOT_CONNECTED},
{@link #BACK_PRESSURED}, {@link #ADMIN_ACTION}, {@link #CLOSED}, or {@link #MAX_POSITION_EXCEEDED}.
@throws IllegalArgumentException if the length is greater than {@link #maxPayloadLength()} within an MTU.
@see BufferClaim#commit()
@see BufferClaim#abort()
Try to claim a range in the publication log into which a message can be written with zero copy semantics . Once the message has been written then { @link BufferClaim#commit () } should be called thus making it available . <p > <b > Note : < / b > This method can only be used for message lengths less than MTU length minus header . If the claim is held after the publication is closed or the client dies then it will be unblocked to reach end - of - stream ( EOS ) . <pre > { @code final BufferClaim bufferClaim = new BufferClaim () ;