Completed
Push — master ( d118af...3d5195 )
by Tomas
07:29 queued 04:09
created

examples/rabbitmq/emitter.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
declare(strict_types=1);
3
4
use Tomaj\Hermes\Driver\RabbitMqDriver;
5
use Tomaj\Hermes\Emitter;
6
use Tomaj\Hermes\Message;
7
use PhpAmqpLib\Connection\AMQPStreamConnection;
8
9
require_once __DIR__.'/../../vendor/autoload.php';
10
11
12
$queueName = 'hermes_queue';
13
$connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest', '/');
14
$channel = $connection->channel();
15
$channel->queue_declare($queueName, false, false, false, false);
16
$driver = new RabbitMqDriver($channel, $queueName);
0 ignored issues
show
Deprecated Code introduced by
The class Tomaj\Hermes\Driver\RabbitMqDriver has been deprecated with message: use LazyRabbitMqDriver instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
17
18
$emitter = new Emitter($driver);
19
20
$counter = 1;
21 View Code Duplication
while (true) {
22
    $emitter->emit(new Message('type1', ['message' => $counter]));
23
    echo "Emited message $counter\n";
24
    $counter++;
25
    sleep(1);
26
}
27