Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
treat committed offset as next fetch, not last
Browse files Browse the repository at this point in the history
this brings the behavior of the balanced consumer in line with the java implementation
  • Loading branch information
ducas committed Apr 28, 2016
1 parent d4c2dda commit 9fc7b5c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void CommitOffsets()
var topicDirs = new ZKGroupTopicDirs(this.config.GroupId, topic.Key);
foreach (KeyValuePair<int, PartitionTopicInfo> partition in topic.Value)
{
var newOffset = partition.Value.ConsumeOffset;
var newOffset = partition.Value.ConsumeOffset + 1;
try
{
if (partition.Value.ConsumeOffsetValid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,26 +501,24 @@ private void AddPartitionTopicInfo(ZKGroupTopicDirs topicDirs, string partition,

//if first time starting a consumer, set the initial offset based on the config
long offset = -1;
long offsetCommited = -1;
if (offsetCommitedString != null)
{
offsetCommited = long.Parse(offsetCommitedString);
offset = offsetCommited + 1;
offset = long.Parse(offsetCommitedString);
}
Logger.InfoFormat("Final offset {0} for topic {1} partition {2} OffsetCommited {3}"
, offset, topic, partition, offsetCommited);
Logger.InfoFormat("Final offset {0} for topic {1} partition {2}."
, offset, topic, partition);

var queue = this.queues[new Tuple<string, string>(topic, consumerThreadId)];
var partTopicInfo = new PartitionTopicInfo(
topic,
leader,
partitionId,
queue,
offsetCommited,
offset,
offset,
offset,
this.config.FetchSize,
offsetCommited);
offset);
partTopicInfoMap[partitionId] = partTopicInfo;
Logger.InfoFormat("{0} selected new offset {1}", partTopicInfo, offset);
}
Expand Down

0 comments on commit 9fc7b5c

Please sign in to comment.