Coder Social home page Coder Social logo

humusamqp's Introduction

Humus Amqp

PHP 7 AMQP library

Build Status Coverage Status Gitter Documentation Status

Documentation powered by Read the Docs.

Overview

PHP 7 AMQP libray supporting multiple drivers and providing full-featured Consumer, Producer, and JSON-RPC Client / Server implementations.

The JSON-RPC part implements JSON-RPC 2.0 Specification.

Current supported drivers are: php-amqp and PhpAmqpLib.

php-amqp needs at least to be v1.9.1 php-amqplib needs at least to be v2.7.0

This library ships with container-interop factories that help you setting up everything.

Installation

You can install prolic/humus-amqp via composer by adding "prolic/humus-amqp": "^1.1" as requirement to your composer.json.

Usage

Exchange

$exchangeName = 'test-exchange';
$exchange = ExchangeFactory::$exchangeName($container);

$exchange->publish('test-message');

Queue

$queueName = 'test-queue';
$queue = QueueFactory::$queueName($container);

$message = $queue->get();
$queue->ack($message->getDeliveryTag());

Producer

$producerName = 'test-producer';
$producer = ProducerFactory::$producerName($container);

$producer->confirmSelect();
$producer->publish(['foo' => 'bar'], 'my-routing-key');
$producer->waitForConfirm();

JSON RPC Client

$clientName = 'my-client';
$client = JsonRpcClientFactory::$clientName($container);
$client->addRequest(new JsonRpcRequest('my-server', 'method', ['my' => 'params'], 'id-1'));
$client->addRequest(new JsonRpcRequest('my-server', 'method', ['my' => 'other_params'], 'id-2'));
$responseCollection = $client->getResponseCollection();

JSON RPC Server

$serverName = 'my-server';
$server = JsonRpcServerFactory::$serverName($container);
$server->consume();

Notes

AMQP-Extension

  1. We recommend using php-amqp >=v1.9.1 or compiling it from master, if you encounter any problems with the amqp extension, check their issue tracker, first.

The ext-amqp driver is the most performant. Benchmarks are added soon.

PhpAmqpLib

  1. When using php-amqplib as driver, it's worth point out, that a StreamConnection (same goes for SSLConnection) does not have the possibility to timeout. If you want to let the consumer timeout, when no more messages are received, you should use the SocketConnection instead (assuming you don't need an SSL connection).

  2. When using php-amqplib as driver and you're using the LazyConnection, you should not create the channel yourself, call instead $channel = $connection->newChannel()

Support

Contribute

Please feel free to fork and extend existing or add new plugins and send a pull request with your changes! To establish a consistent code quality, please provide unit tests for all your changes and may adapt the documentation.

License

Released under the MIT.

humusamqp's People

Contributors

prolic avatar oqq avatar basz avatar yethee avatar cwoskoski avatar marinovdf avatar thomasvargiu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.