Skip to content

refs #664: message handling on StopConsumerException fix #665

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

Merged
merged 1 commit into from
Nov 4, 2021

Conversation

Eloar
Copy link
Contributor

@Eloar Eloar commented Oct 19, 2021

Fixed message handling on StopConsumerException in BatchConsumer as it ignored process flag entirely

// Reject and drop
$this->getMessageChannel($deliveryTag)->basic_reject($deliveryTag, false);
} else {
} elseif ($processFlag !== ConsumerInterface::MSG_ACK_SENT) {
// Remove message from queue only if callback return not false
$this->getMessageChannel($deliveryTag)->basic_ack($deliveryTag);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

what happens for "else" case if there are cases ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what do you mean by 'cases'?
ConsumerInterface::MSG_ACK_SENT means ACK was already sent, so another ACK should not be sent

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps there is no logical "else" part, but this code style is quite confusing. I would recommened to have "else" part. Something like this:

} elseif ($processFlag === ConsumerInterface::MSG_ACK_SENT) {
    // do nothing, ack already sent
} else {
    // Remove message from queue only if callback return not false
    $this->getMessageChannel($deliveryTag)->basic_ack($deliveryTag);
}

This does exactly the same and has better readability. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that sounds sane to make it bit more readable

@mihaileu mihaileu requested a review from ramunasd October 22, 2021 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants