Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the shutdown event from the queue before executing the shudown… #642

Merged
merged 2 commits into from
Nov 1, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ RecordFlow evictAckedEventAndScheduleNextEvent(RecordsDeliveryAck recordsDeliver
flowToBeReturned = recordsRetrievedContext.getRecordFlow();
// Try scheduling the next event in the queue or execute the subscription shutdown action.
if (!recordsDeliveryQueue.isEmpty()) {
recordsDeliveryQueue.peek().executeEventAction(subscriber);
recordsDeliveryQueue.peek().executeEventAction(subscriber, recordsDeliveryQueue);
}
} else {
// Check if the mismatched event belongs to active flow. If publisher receives an ack for a
Expand Down Expand Up @@ -225,9 +225,15 @@ RecordsRetrieved getRecordsRetrieved() {
}

// This method is not thread-safe. You need to acquire a lock in the caller in order to execute this.
void executeEventAction(Subscriber<? super RecordsRetrieved> subscriber) {
void executeEventAction(Subscriber<? super RecordsRetrieved> subscriber, BlockingQueue<RecordsRetrievedContext> recordsDeliveryQueue) {
recordsOrShutdownEvent.apply(recordsEvent -> subscriber.onNext(recordsEvent),
shutdownEvent -> shutdownEvent.getSubscriptionShutdownAction().run());
shutdownEvent -> handleShutdownEvent(shutdownEvent, recordsDeliveryQueue));
}

private void handleShutdownEvent(SubscriptionShutdownEvent shutdownEvent, BlockingQueue<RecordsRetrievedContext> recordsDeliveryQueue) {
//Removing the Shutdown Event from the queue before executing the Shutdown action.
recordsDeliveryQueue.poll();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add this to the ShutdownEvent runnable, rather than having a new method here.

shutdownEvent.getSubscriptionShutdownAction().run();
}
}

Expand Down