File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change 33namespace OldSound \RabbitMqBundle \Command ;
44
55use OldSound \RabbitMqBundle \RabbitMq \BaseConsumer as Consumer ;
6+ use PhpAmqpLib \Exception \AMQPTimeoutException ;
67use Symfony \Component \Console \Input \InputArgument ;
78use Symfony \Component \Console \Input \InputInterface ;
89use Symfony \Component \Console \Input \InputOption ;
@@ -19,7 +20,13 @@ abstract protected function getConsumerService();
1920 public function stopConsumer ()
2021 {
2122 if ($ this ->consumer instanceof Consumer) {
23+ // Process current message, then halt consumer
2224 $ this ->consumer ->forceStopConsumer ();
25+
26+ // Halt consumer if waiting for a new message from the queue
27+ try {
28+ $ this ->consumer ->stopConsuming ();
29+ } catch (AMQPTimeoutException $ e ) {}
2330 } else {
2431 exit ();
2532 }
You can’t perform that action at this time.
0 commit comments