|
60 | 60 | import org.apache.pulsar.broker.service.persistent.DispatchRateLimiter.Type;
|
61 | 61 | import org.apache.pulsar.broker.transaction.buffer.exceptions.TransactionNotSealedException;
|
62 | 62 | import org.apache.pulsar.client.impl.Backoff;
|
| 63 | +import org.apache.pulsar.common.api.proto.PulsarApi; |
63 | 64 | import org.apache.pulsar.common.api.proto.PulsarApi.CommandSubscribe.SubType;
|
64 | 65 | import org.apache.pulsar.common.naming.TopicName;
|
65 | 66 | import org.apache.pulsar.common.policies.data.DispatchRate;
|
@@ -119,7 +120,7 @@ public PersistentDispatcherMultipleConsumers(PersistentTopic topic, ManagedCurso
|
119 | 120 | public PersistentDispatcherMultipleConsumers(PersistentTopic topic, ManagedCursor cursor, Subscription subscription,
|
120 | 121 | boolean allowOutOfOrderDelivery) {
|
121 | 122 | super(subscription);
|
122 |
| - this.serviceConfig = topic.getBrokerService().getPulsar().getConfig(); |
| 123 | + this.serviceConfig = topic.getBrokerService().pulsar().getConfiguration(); |
123 | 124 | this.cursor = cursor;
|
124 | 125 | this.lastIndividualDeletedRangeFromCursorRecovery = cursor.getLastIndividualDeletedRange();
|
125 | 126 | this.name = topic.getName() + " / " + Codec.decode(cursor.getName());
|
@@ -844,6 +845,24 @@ public void initializeDispatchRateLimiterIfNeeded(Optional<Policies> policies) {
|
844 | 845 | }
|
845 | 846 | }
|
846 | 847 |
|
| 848 | + @Override |
| 849 | + public boolean trackDelayedDelivery(long ledgerId, long entryId, PulsarApi.MessageMetadata msgMetadata) { |
| 850 | + if (!topic.isDelayedDeliveryEnabled()) { |
| 851 | + // If broker has the feature disabled, always deliver messages immediately |
| 852 | + return false; |
| 853 | + } |
| 854 | + synchronized (this) { |
| 855 | + if (!delayedDeliveryTracker.isPresent()) { |
| 856 | + // Initialize the tracker the first time we need to use it |
| 857 | + delayedDeliveryTracker = Optional |
| 858 | + .of(topic.getBrokerService().getDelayedDeliveryTrackerFactory().newTracker(this)); |
| 859 | + } |
| 860 | + |
| 861 | + delayedDeliveryTracker.get().resetTickTime(topic.getDelayedDeliveryTickTimeMillis()); |
| 862 | + return delayedDeliveryTracker.get().addMessage(ledgerId, entryId, msgMetadata.getDeliverAtTime()); |
| 863 | + } |
| 864 | + } |
| 865 | + |
847 | 866 | protected synchronized Set<PositionImpl> getMessagesToReplayNow(int maxMessagesToRead) {
|
848 | 867 | if (!redeliveryMessages.isEmpty()) {
|
849 | 868 | return redeliveryMessages.getMessagesToReplayNow(maxMessagesToRead);
|
|
0 commit comments