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 producer part. |
||
12 | * It send a message with random body until it stop |
||
13 | */ |
||
14 | require_once __DIR__.'/../vendor/autoload.php'; |
||
15 | |||
16 | use Swarrot\Broker\Message; |
||
17 | use Swarrot\Broker\MessagePublisher\StatefulStompMessagePublisher; |
||
0 ignored issues
–
show
|
|||
18 | |||
19 | $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...
|
|||
20 | $client->setLogin('stompUser', 'stompPass'); |
||
21 | $client->setVhostname('/'); |
||
22 | $client->connect(); |
||
23 | $stomp = new StatefulStompMessagePublisher($client); |
||
24 | |||
25 | while (true) { |
||
26 | $items = ['good', 'nice', 'wrong']; |
||
27 | $stomp->publish(new Message($items[array_rand($items)]), '/exchange/chat'); |
||
28 | sleep(1); |
||
29 | } |
||
30 |
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