Giter Club home page Giter Club logo

php-uamqp's Introduction

azure-uaqmp-c php bindings

This extensions brings to php bindings for Azure uAMQP C Library, a general purpose C library for AMQP 1.0.

PHP supported Versions

PHP Version Supported
7.2
7.3
7.4

Development

Download repository and then initialize submodules (dependencies)

git clone [email protected]:norzechowicz/php-uamqp.git --recursive
cd php-uamqp
git submodule update --init --recursive 

cd ./ext

PHP uAQMP API

Below you can find public API (classes/functions/constants/interfaces) of the extension, since this project is still under development, those methods might change. Do not use at production, it was never tested anywhere.

UAMQP\Connection

UAMQP\Connection::__construct(string $host, int $port, string $policyName, string $policyKey)
UAMQP\Connection::enableDebugMode() : void
UAMQP\Connection::disableDebugMode() : void
UAMQP\Connection::host() : string
UAMQP\Connection::port() : int
UAMQP\Connection::policyName() : string
UAMQP\Connection::policyKey() : string

UAMQP\Message

UAMQP\Message::__construct(string $payload)
UAMQP\Message::payload() : string

UAMQP\Destination

UAMQP\Destination::__construct(string $value)
UAMQP\Destination::value() : string

UAMQP\Producer

UAMQP\Producer::__construct(UAMQP\Connection $message)
UAMQP\Producer::sendMessage(UAMQP\Message $message, UAMQP\Destination $destination) : void

UAMQP\Consumer

const \UAMQP\Receiver::RECEIVE_AND_DELETE = 0;
const \UAMQP\Receiver::PEAK_AND_LOCK = 1;

\UAMQP\Consumer::__construct(\UAMQP\Connection $message)

\UAMQP\Consumer::open(\UAMQP\Destination $destination, int $settleMode = \UAMQP\Receiver::RECEIVE_AND_DELETE) : void
UAMQP\Consumer::receive() : ?\UAMQP\Message
UAMQP\Consumer::accept() : void
UAMQP\Consumer::release() : void
UAMQP\Consumer::reject(string $errorCondition, string $errorDescription) : void
UAMQP\Consumer::close() : void

Examples

Opening connection, creating producer, publishing couple messages and consuming them with consumer in RECEIVE_AND_DELETE settle mode (messages deleted when received).

<?php

$connection = new \UAMQP\Connection(getenv('PHP_UAMQP_TEST_SB_HOST'), 5671, getenv('PHP_UAMQP_TEST_SB_POLICY_NAME'), getenv('PHP_UAMQP_TEST_SB_POLICY_KEY'));

$producer = new \UAMQP\Producer($connection);
$destination = new \UAMQP\Destination(getenv('PHP_UAMQP_TEST_SB_DESTINATION'));

$producer->sendMessage(new \UAMQP\Message($payload = "this is some random test message 1 " . time()), $destination);
$producer->sendMessage(new \UAMQP\Message($payload = "this is some random test message 2 " . time()), $destination);
$producer->sendMessage(new \UAMQP\Message($payload = "this is some random test message 3 " . time()), $destination);
$producer->sendMessage(new \UAMQP\Message($payload = "this is some random test message 4 " . time()), $destination);

$consumer = new \UAMQP\Consumer($connection, \UAMQP\Consumer::RECEIVE_AND_DELETE);

$i = 0;

$consumer->open($destination);

for ($t = 0; $t < 10; $t++) {
    $message = $consumer->receive();

    if ($message) {
        $i++;
        var_dump($i, $message);

        continue ;
    }

    if ($i >= 4) {
        break;
    }

    usleep(250000);
}

php-uamqp's People

Contributors

norberttech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jonatansantana

php-uamqp's Issues

Add Sender state

On SenderObject there should be state() getter that would return one of following values:

  Idle
  Opening
  Open
  Closing
  Error

Add Consumer state

Consumer object should get state() getter that will return one of following values:

Idle
Opening
Open
Closing
Error 

Add message send result

Each message should have a sending result, one of following values should be allowed:

Ok
Error
Timeout
Cancelled

Add message send state

WaitingToBeSent
WaitingForSendAck
SendComplete
SendFailed
ReceivedUnsettled
ReceivedSettled

[Question] Use in Production

Can this already be used in production?

Is there any abstraction for laravel framework with the AMQP protocol?

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.