Closed
Description
So I noticed that the Consumer can only be stopped when a new message arrives (#89). I think this is because of this line https://github.com/videlalvaro/RabbitMqBundle/blob/b546af972552a43c1fd3e23226df793b6f709d5e/RabbitMq/Consumer.php#L47
So I was thinking about how to fix this. What if we'd run that while
with a AMQPTimeout inside another while(true)
? This is how PHP Resque solves this.
Something like this:
public function consume($msgAmount)
{
$this->target = $msgAmount;
$this->setupConsumer();
while(true) {
$this->maybeStopConsumer();
try {
while (count($this->getChannel()->callbacks)) {
$this->maybeStopConsumer();
$this->getChannel()->wait(null, false, $this->getIdleTimeout());
}
} catch(\PhpAmqpLib\Exception\AMQPTimeoutException $exception) {
echo "Timeout, restart\n";
}
}
}
``
Metadata
Metadata
Assignees
Labels
No labels