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

fix: commit topic partitions end offsets #194

Open
wants to merge 2 commits into
base: main
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 @@ -78,7 +78,8 @@ public Map<TopicPartition, OffsetAndMetadata> updateOffsets(Map<TopicPartition,
TopicPartition topicPartition = entry.getKey();

if (topicPartitionToOffsetMap.containsKey(topicPartition)) {
committedOffsets.put(topicPartition, new OffsetAndMetadata(topicPartitionToOffsetMap.get(topicPartition)));
Long endOffset = topicPartitionToOffsetMap.get(topicPartition) + 1;
committedOffsets.put(topicPartition, new OffsetAndMetadata(endOffset));
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/test/java/com/ably/kafka/connect/AblyBatchClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ public void testSendsAblyBatchApiRequests() throws ChannelSinkConnectorConfig.Co
)
);
assertEquals(Map.of(
new TopicPartition("topic1", 0), new OffsetAndMetadata(1),
new TopicPartition("topic1", 1), new OffsetAndMetadata(4)
new TopicPartition("topic1", 0), new OffsetAndMetadata(2),
new TopicPartition("topic1", 1), new OffsetAndMetadata(5)
), offsets);
}

Expand Down Expand Up @@ -334,8 +334,8 @@ public void testPartialFailureSendsFailedRecordsToDlq() throws ChannelSinkConnec
// Offset registry *should* have been updated for both partitions, as we've DLQ'ed failures
assertEquals(
Map.of(
new TopicPartition("topic1", 0), new OffsetAndMetadata(0),
new TopicPartition("topic1", 1), new OffsetAndMetadata(1)
new TopicPartition("topic1", 0), new OffsetAndMetadata(1),
new TopicPartition("topic1", 1), new OffsetAndMetadata(2)
), registry.updateOffsets(
Map.of(
new TopicPartition("topic1", 0), new OffsetAndMetadata(20),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public void testUpdateOffsets() {
Map<TopicPartition, OffsetAndMetadata> result = offsetRegistryService.updateOffsets(preCommitOffsets);

Map<TopicPartition, OffsetAndMetadata> expectedResult = new HashMap<>();
expectedResult.put(new TopicPartition("topic1", 0), new OffsetAndMetadata(3L));
expectedResult.put(new TopicPartition("topic1", 1), new OffsetAndMetadata(2L));
expectedResult.put(new TopicPartition("topic1", 0), new OffsetAndMetadata(4L));
expectedResult.put(new TopicPartition("topic1", 1), new OffsetAndMetadata(3L));

assertEquals(result, expectedResult);
}
Expand Down