Skip to content

Commit

Permalink
Fix race condition on close consumer while reconnect to broker. (apac…
Browse files Browse the repository at this point in the history
…he#7589)

### Modifications

Add state check when connection opened of the consumer. If the consumer state is closing or closed, we don’t need to send the subscribe command
  • Loading branch information
codelipenghui authored Jul 28, 2020
1 parent 76a45f4 commit 0b37b0c
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,14 @@ public void negativeAcknowledge(MessageId messageId) {

@Override
public void connectionOpened(final ClientCnx cnx) {
if (getState() == State.Closing || getState() == State.Closed) {
setState(State.Closed);
closeConsumerTasks();
client.cleanupConsumer(this);
failPendingReceive();
clearReceiverQueue();
return;
}
setClientCnx(cnx);
cnx.registerConsumer(consumerId, this);

Expand Down

0 comments on commit 0b37b0c

Please sign in to comment.