Class IngressSessionDecorator

java.lang.Object
io.aeron.cluster.client.IngressSessionDecorator

public final class IngressSessionDecorator extends Object
Encapsulate applying a client message header for ingress to the cluster.

The client message header is applied to the Publication before the offered buffer.

Note: This class is NOT threadsafe for updating clusterSessionId(long) or leadershipTermId(long). Each publisher thread requires its own instance.

  • Field Details

    • HEADER_LENGTH

      public static final int HEADER_LENGTH
      Length of the session header that will be prepended to the message.
      See Also:
  • Constructor Details

    • IngressSessionDecorator

      public IngressSessionDecorator()
      Construct a new ingress session header wrapper that defaults all fields to Aeron.NULL_VALUE.
    • IngressSessionDecorator

      public IngressSessionDecorator(long clusterSessionId, long leadershipTermId)
      Construct a new session header wrapper.
      Parameters:
      clusterSessionId - that has been allocated by the cluster.
      leadershipTermId - of the current leader.
  • Method Details

    • clusterSessionId

      public IngressSessionDecorator clusterSessionId(long clusterSessionId)
      Reset the cluster session id in the header.
      Parameters:
      clusterSessionId - to be set in the header.
      Returns:
      this for a fluent API.
    • leadershipTermId

      public IngressSessionDecorator leadershipTermId(long leadershipTermId)
      Reset the leadership term id in the header.
      Parameters:
      leadershipTermId - to be set in the header.
      Returns:
      this for a fluent API.
    • offer

      public long offer(Publication publication, DirectBuffer buffer, int offset, int length)
      Non-blocking publish of a partial buffer containing a message plus session header to a cluster.

      This version of the method will set the timestamp value in the header to Aeron.NULL_VALUE.

      Parameters:
      publication - to be offered to.
      buffer - containing message.
      offset - offset in the buffer at which the encoded message begins.
      length - in bytes of the encoded message.
      Returns:
      the same as Publication.offer(DirectBuffer, int, int).