Promoting the interoperability of message queue objects.

Overview

Queue Interoperability

Latest Stable Version Monthly Downloads Total Downloads License

About

queue-interop tries to identify and standardize a common way for PHP programs to create, send, receive and read MQ messages to achieve interoperability.

Through discussions and trials, we try to create a standard, made of common interfaces but also recommendations.

If PHP projects that provide queue implementations begin to adopt these common standards, then PHP applications and projects that use MQs can depend on the common interfaces instead of specific implementations. This facilitates a high-level of interoperability and flexibility that allows users to consume any MQ transport implementation that can be adapted to these interfaces.

The work done in this project is not officially endorsed by the PHP-FIG. We adhere to the spirit and ideals of PHP-FIG.

Installation

You can install this package through Composer:

# Install a Queue Interop compatible transport, for example 
$ composer require enqueue/fs

Examples

Send a message:

<?php

use Enqueue\Fs\FsConnectionFactory;

$context = (new FsConnectionFactory())->createContext();

$context->createProducer()->send(
    $context->createQueue('aQueue'), 
    $context->createMessage('aBody')
);

Consume a message:

<?php

use Enqueue\Fs\FsConnectionFactory;

$context = (new FsConnectionFactory())->createContext();

$consumer = $context->createConsumer($context->createQueue('aQueue'));

$timeout = 5000; // 5sec
if ($message = $consumer->receive($timeout)) {
    // process the message.

    $consumer->acknowledge($message);
}

Find out more here:

Compatible projects

Projects

Implementations

Amqp interop

There is AMQP interop built on top of Queue Interop. It is completly compatible with queue interop and only adds some AMQP specific features:

  • Queue\Exchange declaration
  • Queue\Exchange Binding.
  • Basic consume support.
  • and other AMQP specific features.

Compatible projects

Workflow

Everyone is welcome to join and contribute.

We try to not break BC by creating new interfaces instead of editing existing ones.

While we currently work on interfaces, we are open to anything that might help towards interoperability, may that be code, best practices, etc.

License

MIT license

Comments
  • Consumer trait

    Consumer trait

    • fixes a bug in some implementation where the timeout is not respected (last wait should check for left time)
    • implements a polling interval to fetch messages
    • implements methods to set and get a visibility timeout
    opened by sylfabre 5
  • Quick review of queue-interop with some comments

    Quick review of queue-interop with some comments

    Hi @makasim

    I viewed queue-interop a few months ago but never had time to properly give some feedback when you started the project, sorry.

    Having worked on PSR-11, I can give you a bit of advices if you ever want to push this on the PHP-FIG for a PSR. So here we go:

    PHP 5 vs PHP 7:

    I saw you discussed the issue here (#2). You decided to go for PHP 5 support a few month ago, but the tide has turned since then. Then newly passed PSR-15 is PHP 7+ only and upcoming PSR will be PHP 7+. So you should definitely target PHP 7 now.

    Naming:

    The interfaces are named PsrXxx. For instance PsrMessage. "Psr" does not add any value. On the other hand, you like the Interface suffix. I know many people feel it's wrong to have an Interface suffix (I'm part of those), but there has been a poll on the PHP-FIG mailing list 2 years ago and it was decided to go with the suffix.

    So you should rename your interfaces this way:

    • PsrMessage => MessageInterface

    Immutability:

    PSR-7 objects (RequestInterface and ResponseInterface) are immutable. This is a very nice property to have as it prevents a number of side-effect bugs. It could be useful to have that in Queue-interop also (so you could drop all the setters from Message and replace those with withXxx methods).

    Scope:

    This is a big one. I think your interfaces have way too many methods. You want to cover all the existing features of all queuing systems. Maybe you should rather target what all systems have in common (i.e. send and consume) rather than putting all possible features of all systems in your interface.

    For instance:

    PsrProducer::setDeliveryDelay seems highly suspicious to me. First of all, the "delivery delay" notion could belong to a message rather than to a producer. It can be nice for producers to have default values, but this is an implementation detail, it has nothing to do in an interface. Then, an interface with setters is usually a code smell (if you want to know why, see https://ocramius.github.io/extremely-defensive-php/)

    I really don't have much time to look in depth at queue-interop, but if you can get some people interested on the PHP-FIG mailing list (I know, it's hard), I'm sure you could get a ton of feedback that would probably change quite radically the structure of your interfaces. I started this way with container-interop, and it's really a great learning opportunity when you have all those skilled people looking at your code. So give it another try and try to gather some more feeedback, it's worth it!

    opened by moufmouf 4
  • Move exceptions to specific folder

    Move exceptions to specific folder

    This is only a suggestion, concentrate all Exceptions into Exception folder.

    Example can be viewed in https://github.com/joubertredrat/queue-interop/tree/master/src

    Maybe related to #4

    opened by joubertredrat 3
  • Message Serializations (2)

    Message Serializations (2)

    This PR adjusts the original PR since it stopped being updated after reviews.

    For myself, I've taken the liberty and removed StringBodyOnlyTrait since it's debatable whether it should be part of queue-interop or not. I do think it can be safely discussed in another PR if needed.

    Second, I've removed default value for $body argument, since from my point of view it hardly makes any sense to use empty messages.

    ref #27

    Fixes #27 Supersedes #28

    opened by Steveb-p 2
  • Message interface implementation

    Message interface implementation

    @makasim this is a 2nd PR with:

    • a fix into /src/MessageTrait (there was an $id property that was a copy-paste error. The right one is $messageId
    • no blank line at the end of /src/MessageTrait.php
    • a test for this trait
    • a TestCase to test all the implementations of the trait

    I've used the same logic as with Symfony test https://github.com/symfony/validator/blob/master/Tests/Constraints/AbstractComparisonValidatorTestCase.php#L260 about how to get an instance to test.

    opened by sylfabre 2
  • Traits to implement Interfaces

    Traits to implement Interfaces

    Would you consider a PR with Trait to implement common methods defined by Interfaces?

    I've in mind this Interop\Queue\Message interface.

    Almost all implementations define the same method bodies which makes a lot of code duplicate that could be cleaned up.

    enhancement 
    opened by sylfabre 1
  • Message creation should not depend on context

    Message creation should not depend on context

    Hello, Thanks for the initiative.

    I have a suggestion. Object creations depend on PsrContext, which looks like a technical leak. Also, it brings a strong dependency on the context.

    This is the current interface:

    $context->createProducer()->send(
        $context->createQueue('aQueue'), 
        $context->createMessage('aBody')
    );
    

    With this interface, if I want to write a service pushing a message, it would either depend on:

    • PsrContext, which is technical, and more than what I need (I don't want to consume the message there),
    • or PsrProducer, plus handwritten QueueFactory and MessageFactory to hide the context.

    What about having PsrMessage and PsrQueue as plain PHP objects ?

    $context->createProducer()->send(
        new PsrQueue('aQueue'), 
        new PsrMessage('aBody')
    );
    

    Typically, I would let a dependency injection container manage PsrProducer instantiation. Then, my business class would just depend on the producer to send messages.

    The producer being provided by the context has all necessary data to decorate the message and queue with technical information, without the end developer having to specify it.

    This is in my opinion more DX. It would also reduce the PsrContext interface responsibility to PsrConsumer and PsrProducer creation.

    opened by gitomato 1
  • Get rid of Psr prefix. Move exceptions to subfolder.

    Get rid of Psr prefix. Move exceptions to subfolder.

    For example:

    \Interop\Queue\PsrContext -> \Interop\Queue\Context
    \Interop\Queue\PsrQueue -> \Interop\Queue\Queue
    
    \Interop\Queue\InvalidMessageException -> \Interop\Queue\Exception\InvalidMessageException
    
    opened by makasim 0
  • Still maintained?

    Still maintained?

    Is this effort still maintained? It appears to have no stable releases, just alphas, but Packagist reports a whole crapload of dependent packages and millions of installs. I'm not sure what to make of that. The most recent alpha tag also doesn't list PHP 8 compatibility, but master does.

    Context: I am investigating possible queue solutions for TYPO3 and this is one I am considering. But if it's not actively maintained and PHP 8.1-friendly then it's not really an option for us.

    opened by Crell 4
  • Master branch more recent than develop

    Master branch more recent than develop

    The Problem

    Not sure what the Git workflow used here is, but develop, which usually represents the latest unstable version, should probably not be behind master, which usually represents the latest stable.

    Further more, for the reasons mentioned above, the masterbranch should not be the main branch of the repository.

    Suggested Solution

    1. Merge master into develop
    2. Direct features/bugfixes to develop from that point onward.
    3. Make develop the main branch of the repository.
    opened by XedinUnknown 0
  • Why message body is of type string?

    Why message body is of type string?

    Why message body is of type string https://github.com/queue-interop/queue-interop/blob/master/src/Message.php#L19? How can I send objects inside of message body? I need to double encode it? It is weird.

    Java specification definitily says that body can be an object, a stream and so on https://docs.oracle.com/javaee/7/api/javax/jms/Message.html

    opened by strider2038 12
Releases(0.8.1)
Owner
null
Magento 2 Message Queue OS AMQP Broker Implementation

Magento 2 Message Queue AMQP Backend AMQP message queue backend implementation for Rcason_Mq. Installation Require the module via Composer $ composer

Renato 8 Jul 12, 2022
PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects.

?? Yell PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects. Requirement

Zeeshan Ahmad 20 Dec 8, 2018
Deeper is a easy way to compare if 2 objects is equal based on values in these objects. This library is heavily inspired in Golang's reflect.DeepEqual().

Deeper Deeper is a easy way to compare if 2 objects is equal based on values in these objects. This library is heavily inspired in Golang's reflect.De

Joubert RedRat 4 Feb 12, 2022
Creating data transfer objects with the power of php objects. No php attributes, no reflection api, and no other under the hook work.

Super Simple DTO Creating data transfer objects with the power of php objects. No php attributes, no reflection api, and no other under the hook work.

Mohammed Manssour 8 Jun 8, 2023
Beanstalk is a simple, fast work queue.

beanstalkd Simple and fast general purpose work queue. https://beanstalkd.github.io/ See doc/protocol.txt for details of the network protocol. Please

Beanstalkd 6.3k Jan 6, 2023
Use php-fpm as a simple built-in async queue

PHP-FPM Async Queue Use php-fpm as a simple built-in async queue. Based on interoperable queue interfaces Queue Interop. Usage composer makasim/php-fp

Max Kotliar 111 Nov 19, 2022
Queue Management Systems for LPG vendor agencies of Sri Lanka, for the LPG shortages in 2022

gas-queue-mgt Queue Management Systems for LPG vendor agencies of Sri Lanka, for the LPG shortages in 2022 Installation Requirements PHP 7.4 or later

Madhusanka Goonathilake 14 Oct 18, 2022
A lightweight queue based on Redis Stream for webman plugin.

workbunny/webman-rqueue ?? A lightweight queue based on Redis Stream for webman plugin. ?? A lightweight queue based on Redis Stream for webman plugin

workbunny 10 Dec 12, 2022
PHP library for Disque, an in-memory, distributed job queue

disque-php A PHP library for the very promising disque distributed job queue. Features: Support for both PHP (5.5+) and HHVM No dependencies: Fast con

Mariano Iglesias 132 Oct 19, 2022
PHP Web User Queue designed to run on shared hosting

WebUserQueue Introduction This is a web user queueing system written in PHP with a MySQL backend designed to run on shared hosting. It was designed to

Chris 0 Aug 13, 2022
Fully covered with tests, documented by Swagger and dockerized API based on enterprise-level framework with optional queue worker.

symfony-api Fully covered with tests, documented by Swagger and dockerized API based on enterprise-level framework with optional queue worker. ⚙️ Depl

Oleksii Velychko 1 Nov 20, 2022
PHP Lightweight Message Bus supporting CQRS.

Prooph Service Bus PHP 7.1+ lightweight message bus supporting CQRS and Micro Services Important This library will receive support until December 31,

null 440 Nov 20, 2022
Xenon\LaravelBDSms is a sms gateway package for sending text message to Bangladeshi mobile numbers using several gateways like sslcommerz, greenweb, dianahost,metronet in Laravel framework

Xenon\LaravelBDSms is a sms gateway package for sending text message to Bangladeshi mobile numbers using several gateways for Laravel. You should use

Ariful Islam 95 Jan 3, 2023
Get dialogflow fullfilment message in PHP

dialogflow-php PHP Client Library for Dialogflow API v2 Requirements Dialogflow Agent Google Account Credentials file PHP Composer Installation To beg

Emmadi Sumith Kumar 17 Oct 28, 2022
This is an implementation of PSR specification. It allows you to send and consume message with Redis store as a broker.

This is an implementation of PSR specification. It allows you to send and consume message with Redis store as a broker.

Enqueue 35 Nov 4, 2022
Ask your friends to send you an anonymous message without knowing them

Ask your friends to send you an anonymous message without knowing them. ????????

Siavash 1 Apr 16, 2022
⚡ Php snippets, random stuff, demos, functions, fast message system, agnostic and framework free - 100% compactible ;) ⚡

⚡ Php8 FPM Nginx Fast, Scripts, Pearls & Treasures ?? Want to run and test asap ? docker-compose up -d phpgit_php8;ip=$(docker-machine ip default);ech

Benjamin FONTAINE 0 Mar 20, 2022
Ecotone Framework is Service Bus Implementation. It enables message driven architecture and DDD, CQRS, Event Sourcing PHP

This is Read Only Repository To contribute make use of Ecotone-Dev repository. Ecotone is Service Bus Implementation, which enables message driven arc

EcotoneFramework 308 Dec 29, 2022
WordPress block that displays a random "powered by" message, generally meant for footers.

X3P0 Powered By A block that generates a random "Powered by" message. It is meant to replace the typical "Powered by Theme/WordPress" message in foote

X3P0 4 Nov 4, 2022