Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/antidot-framework/message-queue
Message queue for Antidot Framework.
https://github.com/antidot-framework/message-queue
hacktoberfest php queue-workers
Last synced: 3 days ago
JSON representation
Message queue for Antidot Framework.
- Host: GitHub
- URL: https://github.com/antidot-framework/message-queue
- Owner: antidot-framework
- License: bsd-2-clause
- Created: 2020-06-15T15:59:43.000Z (over 4 years ago)
- Default Branch: 1.x.x
- Last Pushed: 2022-12-01T10:01:30.000Z (almost 2 years ago)
- Last Synced: 2024-05-21T07:10:36.274Z (6 months ago)
- Topics: hacktoberfest, php, queue-workers
- Language: PHP
- Homepage: https://queue.antidotfw.io
- Size: 96.7 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Antidot Framework Message Queue
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/antidot-framework/message-queue/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/antidot-framework/message-queue/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/antidot-framework/message-queue/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/antidot-framework/message-queue/?branch=master)
[![Type Coverage](https://shepherd.dev/github/antidot-framework/message-queue/coverage.svg)](https://shepherd.dev/github/antidot-framework/message-queue)
[![Psalm Level](https://shepherd.dev/github/antidot-framework/message-queue/level.svg)](https://shepherd.dev/github/antidot-framework/message-queue)
[![Build Status](https://scrutinizer-ci.com/g/antidot-framework/message-queue/badges/build.png?b=master)](https://scrutinizer-ci.com/g/antidot-framework/message-queue/build-status/master)
[![Code Intelligence Status](https://scrutinizer-ci.com/g/antidot-framework/message-queue/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence)Message queue implementation using [enqueue/enqueue](https://github.com/php-enqueue/enqueue-dev) for Antidot Framework.
```bash
composer require antidot-fw/message-queue
```## Message Queue
> A message queue is an asynchronous communication method. It allows storing messages in the queue system until they are consumed and destroyed.
>Each message is processed only once by a unique consumer.### Different Queue Systems
* Null Queue
* Filesystem Queue
* DBAL Queue
* Redis Queue
* Beanstalk
* Amazon SQSEach implementation will have different configuration details, see concrete documentation section. Furthermore,
you can use any of [systems implemented in the PHP-enqueue package](https://php-enqueue.github.io/transport), making the needed factories.
### UsageYou can define as many contexts as you need. You can bind each context to different queues.
Once you have created a Context class, you can start sending jobs to the queue.
The job should contain the queue name, the message type, and the message itself.```php
get(\Antidot\Queue\Producer::class);
$producer->enqueue(Job::create('some_queue', 'some_message', 'Hola Mundo!!'));
```Start listening a queue
```bash
bin/console queue:start default # "default is the queue name"
```Now you can configure actions for the message types received by the queue.
The action is a callable class that receives a JobPayload as the first parameter.### Jobs and Producer
A Job is a class responsible for transport given data to the queue. It is composed of two parameters: the Queue name as a single string,
and the JobPayload with the data to process in the queue. JsonPayload is a JSON serializable object composed of two other parameters:
the message type and the message data as string or array.Once you have a job class, you need to pass it to the producer to send the message to the queue. See the example below.
```php
get(Producer::class);// Send String Job of type "some_message_type" to "default" queue.
$job1 = Job::create('default', 'some_message_type', 'Hello world!!');
$producer->enqueue($job1);// Send Array Job of type "other_message_type" to "other_queue" queue.
$job2 = Job::create('other_queue', 'other_message_type', ['greet' => 'Hello world!!']);
$producer->enqueue($job2);```
### Actions
The actions are invokable classes that will execute when the queue processes the given message. This class has a unique parameter, the JobPayload.
```php