public class ConcurrentPublication extends Publication
Publications
are created via the Aeron.addPublication(String, int) method, and messages are sent via one of the
Publication.offer(DirectBuffer) methods, or a tryClaim(int, BufferClaim) and BufferClaim.commit()
method combination.
The APIs used for try claim and offer are non-blocking and thread safe.
Note: Instances are threadsafe and can be shared between publishing threads.
Aeron.addPublication(String, int),
BufferClaimADMIN_ACTION, BACK_PRESSURED, channel, channelStatusId, CLOSED, conductor, headerWriter, initialTermId, isClosed, logBuffers, logMetaDataBuffer, MAX_POSITION_EXCEEDED, maxMessageLength, maxPayloadLength, maxPossiblePosition, NOT_CONNECTED, originalRegistrationId, positionBitsToShift, positionLimit, registrationId, sessionId, streamId, termBufferLength| Modifier and Type | Method and Description |
|---|---|
long |
offer(org.agrona.DirectBuffer buffer,
int offset,
int length,
ReservedValueSupplier reservedValueSupplier)
Non-blocking publish of a partial buffer containing a message.
|
long |
offer(DirectBufferVector[] vectors,
ReservedValueSupplier reservedValueSupplier)
Non-blocking publish by gathering buffer vectors into a message.
|
long |
tryClaim(int length,
BufferClaim bufferClaim)
Try to claim a range in the publication log into which a message can be written with zero copy semantics.
|
addDestination, channel, channelStatus, channelStatusId, close, initialTermId, isClosed, isConnected, isOriginal, maxMessageLength, maxPayloadLength, maxPossiblePosition, offer, offer, offer, originalRegistrationId, position, positionLimit, positionLimitId, registrationId, removeDestination, sessionId, streamId, termBufferLengthpublic long offer(org.agrona.DirectBuffer buffer,
int offset,
int length,
ReservedValueSupplier reservedValueSupplier)
offer in class Publicationbuffer - containing message.offset - offset in the buffer at which the encoded message begins.length - in bytes of the encoded message.reservedValueSupplier - ReservedValueSupplier for the frame.Publication.NOT_CONNECTED,
Publication.BACK_PRESSURED, Publication.ADMIN_ACTION, Publication.CLOSED, or Publication.MAX_POSITION_EXCEEDED.public long offer(DirectBufferVector[] vectors, ReservedValueSupplier reservedValueSupplier)
offer in class Publicationvectors - which make up the message.reservedValueSupplier - ReservedValueSupplier for the frame.Publication.NOT_CONNECTED,
Publication.BACK_PRESSURED, Publication.ADMIN_ACTION, Publication.CLOSED, or Publication.MAX_POSITION_EXCEEDED.public long tryClaim(int length,
BufferClaim bufferClaim)
BufferClaim.commit() should be called thus making it available.
Note: This method can only be used for message lengths less than MTU length minus header. If the claim is held for more than the aeron.publication.unblock.timeout system property then the driver will assume the publication thread is dead and will unblock the claim thus allowing other threads to make progress or to reach end-of-stream (EOS).
final BufferClaim bufferClaim = new BufferClaim(); // Can be stored and reused to avoid allocation
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();
}
}
tryClaim in class Publicationlength - of the range to claim, in bytes..bufferClaim - to be populated if the claim succeeds.Publication.NOT_CONNECTED,
Publication.BACK_PRESSURED, Publication.ADMIN_ACTION, Publication.CLOSED, or Publication.MAX_POSITION_EXCEEDED.java.lang.IllegalArgumentException - if the length is greater than Publication.maxPayloadLength() within an MTU.BufferClaim.commit(),
BufferClaim.abort()Copyright © 2014-2018 Real Logic Ltd. All Rights Reserved.