Download the PHP package vladimir-yuldashev/laravel-queue-rabbitmq without Composer

On this page you can find all versions of the php package vladimir-yuldashev/laravel-queue-rabbitmq. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-queue-rabbitmq

RabbitMQ Queue driver for Laravel

Latest Stable Version Build Status Total Downloads License

Support Policy

Only the latest version will get new features. Bug fixes will be provided using the following scheme:

Package Version Laravel Version Bug Fixes Until
13 9 August 8th, 2023 Documentation

Installation

You can install this package via composer using this command:

The package will automatically register itself.

Configuration

Add connection to config/queue.php:

This is the minimal config for the rabbitMQ connection/driver to work.

Optional Queue Config

Optionally add queue options to the config of a connection. Every queue created for this connection, gets the properties.

When you want to prioritize messages when they were delayed, then this is possible by adding extra options.

When you want to publish messages against an exchange with routing-keys, then this is possible by adding extra options.

Note: when using an exchange with routing-key, you probably create your queues with bindings yourself.

In Laravel failed jobs are stored into the database. But maybe you want to instruct some other process to also do something with the message. When you want to instruct RabbitMQ to reroute failed messages to a exchange or a specific queue, then this is possible by adding extra options.

Note: When using failed_job exchange with routing-key, you probably need to create your exchange/queue with bindings yourself.

Horizon support

Starting with 8.0, this package supports Laravel Horizon out of the box. Firstly, install Horizon and then set RABBITMQ_WORKER to horizon.

Horizon is depending on events dispatched by the worker. These events inform Horizon what was done with the message/job.

This Library supports Horizon, but in the config you have to inform Laravel to use the QueueApi compatible with horizon.

Use your own RabbitMQJob class

Sometimes you have to work with messages published by another application.
Those messages probably won't respect Laravel's job payload schema. The problem with these messages is that, Laravel workers won't be able to determine the actual job or class to execute.

You can extend the build-in RabbitMQJob::class and within the queue connection config, you can define your own class. When you specify a job key in the config, with your own class name, every message retrieved from the broker will get wrapped by your own class.

An example for the config:

An example of your own job class:

Or maybe you want to add extra properties to the payload:

If you want to handle raw message, not in JSON format or without 'job' key in JSON, you should add stub for getName method:

Use your own Connection

You can extend the built-in PhpAmqpLib\Connection\AMQPStreamConnection::class or PhpAmqpLib\Connection\AMQPSLLConnection::class and within the connection config, you can define your own class. When you specify a connection key in the config, with your own class name, every connection will use your own class.

An example for the config:

Use your own Worker class

If you want to use your own RabbitMQQueue::class this is possible by extending VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue. and inform laravel to use your class by setting RABBITMQ_WORKER to \App\Queue\RabbitMQQueue::class.

Note: Worker classes must extend VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue

For Example: A reconnect implementation.

If you want to reconnect to RabbitMQ, if the connection is dead. You can override the publishing and the createChannel methods.

Note: this is not best practice, it is an example.

Default Queue

The connection does use a default queue with value 'default', when no queue is provided by laravel. It is possible to change te default queue by adding an extra parameter in the connection config.

Heartbeat

By default, your connection will be created with a heartbeat setting of 0. You can alter the heartbeat settings by changing the config.

SSL Secure

If you need a secure connection to rabbitMQ server(s), you will need to add these extra config options.

Events after Database commits

To instruct Laravel workers to dispatch events after all database commits are completed.

Lazy Connection

By default, your connection will be created as a lazy connection. If for some reason you don't want the connection lazy you can turn it off by setting the following config.

Network Protocol

By default, the network protocol used for connection is tcp. If for some reason you want to use another network protocol, you can add the extra value in your config options. Available protocols : tcp, ssl, tls

Octane support

Starting with 13.3.0, this package supports Laravel Octane out of the box. Firstly, install Octane and don't forget to warm 'rabbitmq' connection in the octane config.

See: https://github.com/vyuldashev/laravel-queue-rabbitmq/issues/460#issuecomment-1469851667

Laravel Usage

Once you completed the configuration you can use the Laravel Queue API. If you used other queue drivers you do not need to change anything else. If you do not know how to use the Queue API, please refer to the official Laravel documentation: http://laravel.com/docs/queues

Lumen Usage

For Lumen usage the service provider should be registered manually as follow in bootstrap/app.php:

Consuming Messages

There are two ways of consuming messages.

  1. queue:work command which is Laravel's built-in command. This command utilizes basic_get. Use this if you want to consume multiple queues.

  2. rabbitmq:consume command which is provided by this package. This command utilizes basic_consume and is more performant than basic_get by ~2x, but does not support multiple queues.

Testing

Setup RabbitMQ using docker-compose:

To run the test suite you can use the following commands:

If you receive any errors from the style tests, you can automatically fix most, if not all the issues with the following command:

Contribution

You can contribute to this package by discovering bugs and opening issues. Please, add to which version of package you create pull request or issue. (e.g. [5.2] Fatal error on delayed job)


All versions of laravel-queue-rabbitmq with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
ext-json Version *
illuminate/queue Version ^10.0|^11.0
php-amqplib/php-amqplib Version ^v3.6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vladimir-yuldashev/laravel-queue-rabbitmq contains the following files

Loading the files please wait ....