public abstract class AbstractDispatcherMultipleConsumers extends AbstractBaseDispatcher
| Modifier and Type | Field and Description |
|---|---|
protected CopyOnWriteArrayList<Consumer> |
consumerList |
protected com.carrotsearch.hppc.ObjectSet<Consumer> |
consumerSet |
protected int |
currentConsumerRoundRobinIndex |
protected static int |
FALSE |
protected static AtomicIntegerFieldUpdater<AbstractDispatcherMultipleConsumers> |
IS_CLOSED_UPDATER |
protected static int |
TRUE |
serviceConfig, subscription| Modifier | Constructor and Description |
|---|---|
protected |
AbstractDispatcherMultipleConsumers(Subscription subscription,
ServiceConfiguration serviceConfig) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
cancelPendingRead() |
boolean |
canUnsubscribe(Consumer consumer) |
CopyOnWriteArrayList<Consumer> |
getConsumers() |
Consumer |
getNextConsumer()
Broker gives more priority while dispatching messages.
|
Consumer |
getRandomConsumer()
Get random consumer from consumerList.
|
org.apache.pulsar.common.api.proto.CommandSubscribe.SubType |
getType() |
boolean |
isClosed() |
abstract boolean |
isConsumerAvailable(Consumer consumer) |
boolean |
isConsumerConnected() |
computeReadLimits, filterEntriesForConsumer, filterEntriesForConsumer, isConsumersExceededOnSubscription, isConsumersExceededOnSubscription, peekStickyKey, resetCloseFuture, updateEntryWrapperWithMetadataclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddConsumer, addUnAckedMessages, checkAndUnblockIfStuck, clearDelayedMessages, close, consumerFlow, cursorIsReset, disconnectActiveConsumers, disconnectAllConsumers, disconnectAllConsumers, getNumberOfDelayedMessages, getRateLimiter, getRedeliveryTracker, initializeDispatchRateLimiterIfNeeded, markDeletePositionMoveForward, redeliverUnacknowledgedMessages, redeliverUnacknowledgedMessages, removeConsumer, reset, trackDelayedDelivery, updateRateLimiterprotected final CopyOnWriteArrayList<Consumer> consumerList
protected final com.carrotsearch.hppc.ObjectSet<Consumer> consumerSet
protected volatile int currentConsumerRoundRobinIndex
protected static final int FALSE
protected static final int TRUE
protected static final AtomicIntegerFieldUpdater<AbstractDispatcherMultipleConsumers> IS_CLOSED_UPDATER
protected AbstractDispatcherMultipleConsumers(Subscription subscription, ServiceConfiguration serviceConfig)
public boolean isConsumerConnected()
public CopyOnWriteArrayList<Consumer> getConsumers()
public boolean canUnsubscribe(Consumer consumer)
public boolean isClosed()
public org.apache.pulsar.common.api.proto.CommandSubscribe.SubType getType()
public abstract boolean isConsumerAvailable(Consumer consumer)
protected void cancelPendingRead()
public Consumer getNextConsumer()
Broker gives more priority while dispatching messages. Here, broker follows descending priorities. (eg: 0=max-priority, 1, 2,..)Broker will first dispatch messages to max priority-level consumers if they have permits, else broker will consider next priority level consumers. Also on the same priority-level, it selects consumer in round-robin manner.
If subscription has consumer-A with priorityLevel 1 and Consumer-B with priorityLevel 2 then broker will dispatch messages to only consumer-A until it runs out permit and then broker starts dispatching messages to Consumer-B.
Consumer PriorityLevel Permits C1 0 2 C2 0 1 C3 0 1 C4 1 2 C5 1 1 Result of getNextConsumer(): C1, C2, C3, C1, C4, C5, C4
Algorithm: 1. consumerList: it stores consumers in sorted-list: max-priority stored first 2. currentConsumerRoundRobinIndex: it always stores last served consumer-index Each time getNextConsumer() is called:1. It always starts to traverse from the max-priority consumer (first element) from sorted-list 2. Consumers on same priority-level will be treated equally and it tries to pick one of them in round-robin manner 3. If consumer is not available on given priority-level then only it will go to the next lower priority-level consumers 4. Returns null in case it doesn't find any available consumer
public Consumer getRandomConsumer()
Copyright © 2017–2022 Apache Software Foundation. All rights reserved.