Skip to content

Commit c5ee228

Browse files
authored
Merge pull request #412 from nfqde/master
Fix for consumer with empty queue not being able to handle SIGTERM and SIGINT
2 parents 902d96e + d3fef7f commit c5ee228

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

RabbitMq/BaseConsumer.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,15 @@ public function start($msgAmount = 0)
3434
}
3535
}
3636

37+
/**
38+
* Tell the server you are going to stop consuming.
39+
*
40+
* It will finish up the last message and not send you any more.
41+
*/
3742
public function stopConsuming()
3843
{
39-
$this->getChannel()->basic_cancel($this->getConsumerTag());
44+
// This gets stuck and will not exit without the last two parameters set.
45+
$this->getChannel()->basic_cancel($this->getConsumerTag(), false, true);
4046
}
4147

4248
protected function setupConsumer()

0 commit comments

Comments
 (0)