Total Complexity | 7 |
Total Lines | 58 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
17 | abstract class RabbitReceiver extends RabbitMQ |
||
18 | { |
||
19 | /** |
||
20 | * The handler of the messages received from queue |
||
21 | * |
||
22 | * @param mixed $message Received from rabbitmq queue |
||
23 | * @return void |
||
24 | */ |
||
25 | protected function handler($message) |
||
26 | { |
||
27 | // Simple print on getted message from the queue |
||
28 | print_r($message->body); |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * Infinite loop for listen the queue messages |
||
33 | * |
||
34 | * @return void |
||
35 | */ |
||
36 | protected function consume() |
||
37 | { |
||
38 | $callback = function($message) { $this->handler($message); }; |
||
39 | $this->channel->basic_consume($this->getQueue(), 'consumer', false, $this->getReply(), false, false, $callback); |
||
40 | |||
41 | $pid = pcntl_fork(); |
||
42 | |||
43 | if ($pid == -1) { |
||
44 | echo 'annot fork consume proccess...'; |
||
45 | return; |
||
46 | } |
||
47 | |||
48 | if ($pid) { |
||
49 | while (true) { |
||
50 | $this->send_heartbeat(); |
||
51 | sleep(10); |
||
52 | } |
||
53 | } else { |
||
54 | while (count($this->channel->callbacks)) |
||
55 | { |
||
56 | $this->channel->wait(); |
||
57 | } |
||
58 | } |
||
59 | |||
60 | $this->closeConnection(); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * work on PhpAmqpLib 2.9.2 |
||
65 | */ |
||
66 | private function send_heartbeat() |
||
75 | } |
||
76 | } |
||
77 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths