Class Dispatcher

java.lang.Object
io.camunda.zeebe.util.sched.Actor
io.camunda.zeebe.dispatcher.Dispatcher
All Implemented Interfaces:
CloseableSilently, AsyncClosable, ConcurrencyControl, AutoCloseable

public class Dispatcher extends Actor
Component for sending and receiving messages between different threads.
  • Method Details

    • getName

      public String getName()
      Overrides:
      getName in class Actor
    • onActorStarted

      protected void onActorStarted()
      Overrides:
      onActorStarted in class Actor
    • onActorClosing

      protected void onActorClosing()
      Overrides:
      onActorClosing in class Actor
    • claimSingleFragment

      public long claimSingleFragment(ClaimedFragment claim, int length)
      Claim a fragment of the buffer with the given length. Use ClaimedFragment.getBuffer() to write the message and finish the operation using ClaimedFragment.commit() or ClaimedFragment.abort(). Note that the claim operation can fail if the publisher limit or the buffer partition size is reached.
      Returns:
      the position for the fragment. Otherwise, the return value is negative.
    • claimSingleFragment

      public long claimSingleFragment(ClaimedFragment claim, int length, int streamId)
      Claim a fragment of the buffer with the given length and stream id. Use ClaimedFragment.getBuffer() to write the message and finish the operation using ClaimedFragment.commit() or ClaimedFragment.abort(). Note that the claim operation can fail if the publisher limit or the buffer partition size is reached.
      Returns:
      the position for the fragment. Otherwise, the return value is negative.
    • claimFragmentBatch

      public long claimFragmentBatch(ClaimedFragmentBatch batch, int fragmentCount, int batchLength)
      Claim a batch of fragments on the buffer with the given length. Use ClaimedFragmentBatch.nextFragment(int, int) to add a new fragment to the batch. Write the fragment message using ClaimedFragmentBatch.getBuffer() and ClaimedFragmentBatch.getFragmentOffset() to get the buffer offset of this fragment. Complete the whole batch operation by calling either ClaimedFragmentBatch.commit() or ClaimedFragmentBatch.abort(). Note that the claim operation can fail if the publisher limit or the buffer partition size is reached.
      Returns:
      the position for the first fragment. Otherwise, the return value is negative.
    • canClaimFragmentBatch

      public boolean canClaimFragmentBatch(int fragmentCount, int batchLength)
      Returns whether a batch of length batchLength, containing fragmentCount fragments, can be claimed by this dispatcher.
      Parameters:
      fragmentCount - the count of fragments in the batch
      batchLength - the total length of the batch (all fragments included), unframed
      Returns:
      true if the batch can be claimed, false otherwise
    • updatePublisherLimit

      public int updatePublisherLimit()
    • openSubscription

      public Subscription openSubscription(String subscriptionName)
      Creates a new subscription with the given name.
      Throws:
      IllegalStateException -
    • if the dispatcher runs in pipeline-mode,
    • if a subscription with this name already exists
    • openSubscriptionAsync

      public ActorFuture<Subscription> openSubscriptionAsync(String subscriptionName)
      Creates a new subscription with the given name asynchronously. The operation fails if a subscription with this name already exists.
    • doOpenSubscription

      protected Subscription doOpenSubscription(String subscriptionName, ActorCondition onConsumption)
    • newSubscription

      protected Subscription newSubscription(int subscriptionId, String subscriptionName, ActorCondition onConsumption)
    • determineLimit

      protected AtomicPosition determineLimit()
    • isClosed

      public boolean isClosed()
    • getLogBuffer

      public LogBuffer getLogBuffer()
    • getMaxFragmentLength

      public int getMaxFragmentLength()
    • getPublisherPosition

      public long getPublisherPosition()
    • toString

      public String toString()
      Overrides:
      toString in class Object