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

Sink Connector should publish all outstanding messages on flush #283

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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 @@ -334,6 +334,8 @@ private ByteString handleValue(Schema schema, Object value, Map<String, String>

@Override
public void flush(Map<TopicPartition, OffsetAndMetadata> partitionOffsets) {
// Publish the incomplete batch now instead of waiting for the maxDelayThresholdMs
publisher.publishAllOutstanding();
log.debug("Flushing...");
// Process results of all the outstanding futures specified by each TopicPartition.
for (Map.Entry<TopicPartition, OffsetAndMetadata> partitionOffset :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ public void testFlushWithNoPublishInPut() throws Exception {
when(publisher.publish(any(PubsubMessage.class))).thenReturn(goodFuture);
task.put(records);
task.flush(partitionOffsets);
verify(publisher, times(1)).publishAllOutstanding();
verify(publisher, times(2)).publish(any(PubsubMessage.class));
verify(goodFuture, times(2)).addListener(any(Runnable.class), any(Executor.class));
}
Expand All @@ -372,6 +373,7 @@ public void testFlushExceptionCase() throws Exception {
when(publisher.publish(any(PubsubMessage.class))).thenReturn(badFuture);
task.put(records);
task.flush(partitionOffsets);
verify(publisher, times(1)).publishAllOutstanding();
verify(publisher, times(1)).publish(any(PubsubMessage.class));
verify(badFuture, times(1)).addListener(any(Runnable.class), any(Executor.class));
}
Expand Down Expand Up @@ -602,6 +604,7 @@ public void testFlushExceptionThenNoExceptionCase() throws Exception {
records = getSampleRecords();
task.put(records);
task.flush(partitionOffsets);
verify(publisher, times(2)).publishAllOutstanding();
verify(publisher, times(4)).publish(any(PubsubMessage.class));
verify(badFuture, times(2)).addListener(any(Runnable.class), any(Executor.class));
verify(goodFuture, times(2)).addListener(any(Runnable.class), any(Executor.class));
Expand Down