Skip to content

Commit d3fef7f

Browse files
author
Eligijus Vitkauskas
committed
Fix for consumer with empty queue not being able to handle SIGTERM and SIGINT
This solution still dispatches "console.terminate" as requested in #372 Fix for #352 #178 #260
1 parent 902d96e commit d3fef7f

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)