Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/puzzle-org/amqp
Manage AMQP messages (publishing and consuming)
https://github.com/puzzle-org/amqp
amqp asynchronous library oop php silex swarrot worker
Last synced: 3 months ago
JSON representation
Manage AMQP messages (publishing and consuming)
- Host: GitHub
- URL: https://github.com/puzzle-org/amqp
- Owner: puzzle-org
- Created: 2016-04-06T21:13:12.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-03-28T08:48:19.000Z (almost 2 years ago)
- Last Synced: 2024-09-19T03:13:27.980Z (5 months ago)
- Topics: amqp, asynchronous, library, oop, php, silex, swarrot, worker
- Language: PHP
- Homepage: https://puzzle-amqp.readthedocs.io/en/latest/index.html
- Size: 394 KB
- Stars: 3
- Watchers: 5
- Forks: 6
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Puzzle AMQP ![PHP >= 8.0](https://img.shields.io/badge/php-%3E%3D%208.0-blue.svg)
===========
PHP 5.6 & 7.x users, please use < 5.x versions.QA
--| Service | Result |
|---------------------------------| --- |
| **Travis CI** (PHP 8.0 .. 8.1) | [![Build Status](https://travis-ci.org/puzzle-org/amqp.svg?branch=master)](https://travis-ci.org/puzzle-org/amqp) |
| **Scrutinizer** | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/puzzle-org/amqp/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/puzzle-org/amqp/?branch=master) |
| **Code coverage** | [![codecov](https://codecov.io/gh/puzzle-org/amqp/branch/master/graph/badge.svg)](https://codecov.io/gh/puzzle-org/amqp) |
| **Packagist** | [![Latest Stable Version](https://poser.pugx.org/puzzle/amqp/v/stable.png)](https://packagist.org/packages/puzzle/amqp) [![Total Downloads](https://poser.pugx.org/puzzle/amqp/downloads.svg)](https://packagist.org/packages/puzzle/amqp) |Configuration
-------------```yml
# amqp.yml
broker:
host: myRabbit
port: 5672
login: guest
password: guest
vhost: /
global:
disallowSilentDropping: false# app.yml
id: myApp
```Usage
-----
## Sending a message```php
'myRabbit',
'amqp/broker/login' => 'guest',
'amqp/broker/password' => 'guest',
'amqp/broker/vhost' => '/',
'app/id' => 'myApp',
));$client = new Pecl($configuration);
$message = new Message('my.routing.key');
$message->setJson([
'key' => 'value',
'key2' => 'value2',
]);$client->publish('myExchange', $message);
```
## Consuming a message### Worker declaration :
```php
'rabbitmq',
'amqp/broker/login' => 'guest',
'amqp/broker/password' => 'guest',
'amqp/broker/vhost' => '/',
'app/id' => 'myApp',
));$consumer = new Consumers\Simple();
$worker = new ExampleWorker();
$consumer->consume(
new ProcessorInterfaceAdapter($worker),
new Clients\Pecl($configuration),
'queue.name'
);
```
### Worker example :
```php
logger = new NullLogger();
}public function process(ReadableMessage $message): void
{
// your code here
}
}
```BC Breaks changelog
-------------------
**4.x -> 5.x**- Drop support for php 5.6 & 7.x
- Worker now catch Throwable, not only Exceptions
- Consumer / Worker / WorkerContext signature change**3.x -> 4.x**
- Chunk management introduced in 3.1 has been refactored and made easier : just use Streamed* bodies and same client as usual
**2.x -> 3.x**
- Message hooks has been removed
- Raw & Json implementations of WritableMessage has been replaced by Message + implementations of Body (Text, Json, Binary)
- Message interface has been renamed into MessageMetadata
- Some specific features removed from WorkerContext
- Getter for specific headers removed from MessageAdapter
- Message InMemory implementation (for unit testing purpose) has been changed
- MessageAdapter must not be directly constructed anymore, use MessageAdapterFactory instead**1.x -> 2.x**
- Drop support for Silex 1.x (in favor of Silex 2.x)