Download the PHP package roslov/queue-bundle without Composer

On this page you can find all versions of the php package roslov/queue-bundle. 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 queue-bundle

Queue Bundle

This package provides the classes needed to work with RabbitMQ.

It is based on RabbitMQ bundle.

Requirements

TODO

Installation and usage

Default bundle configuration

The package could be installed with composer:

Then change the default settings by creating config/packages/roslov_queue.yaml with the content below.

RabbitMQ configuration

This package also installs RabbitMQ bundle. So first, you need to configure RabbitMQ bundle. Follow its documentation. For example:

Consumers and producers

Create DTOs that will be used in consumers and producers, and add them to roslov_queue.payload_mapping (see examples).

Create a consumer that uses Roslov\QueueBundle\Serializer\MessagePayloadSerializer as a serializer:

Add your consumers to old_sound_rabbit_mq.consumers or old_sound_rabbit_mq.multiple_consumers.

Create a producer that extends Roslov\QueueBundle\Producer\BaseProducer and implement getRoutingKey():

Add your producers to old_sound_rabbit_mq.producers.

Create a producer facade to keep all producer calls in one place, by extending BaseProducerFacade and injecting EventProcessor:

The events are stored in DB and are sent on kernel terminate or after message consuming. So you have to create a DB table for events. Currently, only Doctrine with MySQL are supported:

And add the Event entity to the Doctrine config:

Now you can send an event by $producerFacade->sendUserCreatedEvent(123).

The best way to use the event processor is use in inside a transaction to comply the Transactional Outbox pattern. So you have to call the producer facade somewhere in your code, and then flush all events at the end of the transaction:

Do not forget to enable the event processor in roslov_queue.event_processor.enabled if you produce messages.

Note that by default, the transactional outbox support is disabled. To enable it, set roslov_queue.event_processor.instant_delivery to false.

In some microservices, you do not need to use transactional outbox, so events can be sent immediately. In this case, set roslov_queue.event_processor.instant_delivery to true, so both BaseProducerFacade::send() and EventProcessor::save() will be sending the events instantly (without interim saving to DB). This is a default behavior.

For automation tests, you can disable roslov_queue.event_processor.delayed_delivery_subscriber. In this case, the events will be stored in DB but not sent. So you can test your DB whether events where created. Note that this will not work if instant delivery is enabled — the events will be sent instantly.

RPC servers and clients

If you need to use the remote procedure call (RPC), enable roslov_queue.rpc_client.enabled on your client service and roslov_queue.rpc_server.enabled and roslov_queue.rpc_server.exchange on your server service:

The example of an RPC client use:

For an RPC server, add handlers that process commands and return results:

The example of an RPC server handler:

To run the RPC server, use:

Exception events

This bundle allows automatic sending of events about thrown exceptions.

Note that by default, the exception_subscriber is disabled. To enable it, set roslov_queue.exception_subscriber.enabled to true.

The exception subscriber uses the routing key exception-thrown.

Example of exception validator class, that can be passed to the roslov_queue.exception_validator configuration:

If you want to send an exception event manually, use \Roslov\QueueBundle\Sender\ExceptionSender::sendExceptionThrownEvent().

Resending the message

In case something happened, and you need to resend the same message again to the same queue, use return ConsumerInterface::MSG_SINGLE_NACK_REQUEUE; instead of return ConsumerInterface::MSG_ACK; in your consumer.

Testing

Unit testing

The package is tested with PHPUnit. To run tests:

Code style analysis

The code style is analyzed with PHP_CodeSniffer and PSR-12 Ext coding standard. To run code style analysis:


All versions of queue-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.0
ext-json Version *
ext-mbstring Version *
ext-sockets Version *
doctrine/orm Version ^2.7
php-amqplib/rabbitmq-bundle Version ^1.15|^2.10
roslov/log-obfuscator Version ^1.0
symfony/config Version ^3.4|^4.0|^5.0|^6.0|^7.0
symfony/dependency-injection Version ^3.4|^4.0|^5.0|^6.0|^7.0
symfony/framework-bundle Version ^3.4|^4.0|^5.0|^6.0|^7.0
symfony/property-access Version ^3.4|^4.0|^5.0|^6.0|^7.0
symfony/serializer Version ^3.4|^4.0|^5.0|^6.0|^7.0
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 roslov/queue-bundle contains the following files

Loading the files please wait ....