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 3
3
namespace OldSound \RabbitMqBundle \Command ;
4
4
5
5
use OldSound \RabbitMqBundle \RabbitMq \BaseConsumer as Consumer ;
6
+ use PhpAmqpLib \Exception \AMQPTimeoutException ;
6
7
use Symfony \Component \Console \Input \InputArgument ;
7
8
use Symfony \Component \Console \Input \InputInterface ;
8
9
use Symfony \Component \Console \Input \InputOption ;
@@ -19,7 +20,13 @@ abstract protected function getConsumerService();
19
20
public function stopConsumer ()
20
21
{
21
22
if ($ this ->consumer instanceof Consumer) {
23
+ // Process current message, then halt consumer
22
24
$ 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 ) {}
23
30
} else {
24
31
exit ();
25
32
}
You can’t perform that action at this time.
0 commit comments