Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #config/queue.php
- 'rabbitmq' => [
- 'driver' => 'rabbitmq',
- 'connection' => AMQPStreamConnection::class,
- 'options' => [
- 'queue' => [
- 'job' => RabbitMQJob::class,
- 'exchange' => 'logs',
- 'exchange_type' => 'fanout',
- 'exchange_routing_key' => '',
- ],
- ],
- 'worker' => env('RABBITMQ_WORKER', 'default'),
- ]
- #RabbitMQJob.php
- namespace App\Queue\Jobs;
- class RabbitMQJob extends \VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Jobs\RabbitMQJob
- {
- public function fire(): void
- {
- \print_r($this);
- }
- }
- #emit_log.php
- require_once __DIR__.'/vendor/autoload.php';
- use PhpAmqpLib\Connection\AMQPStreamConnection;
- use PhpAmqpLib\Message\AMQPMessage;
- $connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest');
- $channel = $connection->channel();
- $channel->exchange_declare('logs', 'fanout', false, true, false);
- $channel->basic_publish(new AMQPMessage("info: Hello World!"), 'logs');
- $channel->close();
- $connection->close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement