1 | <?php |
||||
2 | /** |
||||
3 | * See http://www.rabbitmq.com/stomp.html for more infos. |
||||
4 | * Run with rabbit stomp plugin. |
||||
5 | * |
||||
6 | * You must enable the plugin |
||||
7 | * `rabbitmq-plugins enable rabbitmq_stomp` |
||||
8 | * You need to create rabbit user (stompUser, stompPass) |
||||
9 | * Guest user have security restriction. See https://github.com/stomp-php/stomp-php/issues/105 |
||||
10 | * |
||||
11 | * This example is the consumer part. |
||||
12 | * It print the message body |
||||
13 | * if the message body is "wrong" the message will be nack |
||||
14 | * else ack all message |
||||
15 | */ |
||||
16 | require_once __DIR__.'/../vendor/autoload.php'; |
||||
17 | |||||
18 | use Swarrot\Broker\Message; |
||||
19 | use Swarrot\Broker\MessageProvider\StatefulStompMessageProvider; |
||||
0 ignored issues
–
show
|
|||||
20 | use Swarrot\Consumer; |
||||
21 | use Swarrot\Processor\Callback\CallbackProcessor; |
||||
22 | |||||
23 | $client = new \Stomp\Client('tcp://localhost:61613'); |
||||
0 ignored issues
–
show
The type
Stomp\Client was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths
Loading history...
|
|||||
24 | $client->setLogin('stompUser', 'stompPass'); |
||||
25 | $client->setVhostname('/'); |
||||
26 | $client->connect(); |
||||
27 | |||||
28 | $stompMessageProvider = new StatefulStompMessageProvider($client, '/queue/stomp_queue'); |
||||
29 | |||||
30 | $processor = new CallbackProcessor(function (Message $message, array $options) use ($stompMessageProvider) { |
||||
0 ignored issues
–
show
The parameter
$options is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
Loading history...
|
|||||
31 | $body = $message->getBody(); |
||||
32 | if ('wrong' == $body) { |
||||
33 | echo "$body NACK\r\n"; |
||||
34 | $stompMessageProvider->nack($message); |
||||
35 | |||||
36 | return; |
||||
37 | } |
||||
38 | echo "$body\r\n"; |
||||
39 | $stompMessageProvider->ack($message); |
||||
40 | }); |
||||
41 | |||||
42 | $consumer = new Consumer($stompMessageProvider, $processor); |
||||
43 | |||||
44 | $consumer->consume([]); |
||||
45 |
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