Skip to content

Commit bd96a63

Browse files
alexbumbaceaskafandri
authored andcommitted
#392 - ack before stopping consumer (#400)
* #392 - ack before stopping consumer * Add new line
1 parent dc96d6e commit bd96a63

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

RabbitMq/Consumer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ protected function processMessageQueueCallback(AMQPMessage $msg, $queueName, $ca
114114
'stacktrace' => $e->getTraceAsString()
115115
)
116116
));
117+
$this->handleProcessMessage($msg, $e->getHandleCode());
117118
$this->stopConsuming();
118119
} catch (\Exception $e) {
119120
$this->logger->error($e->getMessage(), array(
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace OldSound\RabbitMqBundle\RabbitMq\Exception;
4+
5+
6+
use OldSound\RabbitMqBundle\RabbitMq\ConsumerInterface;
7+
8+
class AckStopConsumerException extends StopConsumerException
9+
{
10+
public function getHandleCode()
11+
{
12+
return ConsumerInterface::MSG_ACK;
13+
}
14+
15+
}

RabbitMq/Exception/StopConsumerException.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
namespace OldSound\RabbitMqBundle\RabbitMq\Exception;
4+
use OldSound\RabbitMqBundle\RabbitMq\ConsumerInterface;
45

56
/**
67
* If this exception is thrown in consumer service the message
@@ -11,6 +12,10 @@
1112
*/
1213
class StopConsumerException extends \RuntimeException
1314
{
15+
public function getHandleCode()
16+
{
17+
return ConsumerInterface::MSG_SINGLE_NACK_REQUEUE;
18+
}
1419

1520
}
1621

0 commit comments

Comments
 (0)