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

[ISSUE #116]fix: added queue's some messages may can not be consumed caused by offset init. #117

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -243,7 +243,7 @@ public void open(Configuration parameters) throws Exception {
if (restored) {
initOffsetTableFromRestoredOffsets(messageQueues);
} else {
initOffsets(messageQueues);
initOffsets(messageQueues, false);
}
}

Expand Down Expand Up @@ -370,10 +370,12 @@ private void awaitTermination() throws InterruptedException {
* @param messageQueues
* @throws MQClientException
*/
private void initOffsets(List<MessageQueue> messageQueues) throws MQClientException {
private void initOffsets(List<MessageQueue> messageQueues, boolean added) throws MQClientException {
StartupMode startupMode = startMode;
if(added) startupMode = StartupMode.EARLIEST;
for (MessageQueue mq : messageQueues) {
long offset;
switch (startMode) {
switch (startupMode) {
case LATEST:
consumer.seekToEnd(mq);
offset = consumer.committed(mq);
Expand Down Expand Up @@ -554,7 +556,7 @@ public void initOffsetTableFromRestoredOffsets(List<MessageQueue> messageQueues)
}
if (extMessageQueue.size() != 0) {
log.info("no restoredOffsets for {}, so init offset for these queues", extMessageQueue);
initOffsets(extMessageQueue);
initOffsets(extMessageQueue, true);
}
log.info("init offset table [{}] from restoredOffsets successful.", offsetTable);
}
Expand Down