GithubHelp home page GithubHelp logo

ssi-anik / amqp Goto Github PK

View Code? Open in Web Editor NEW
134.0 6.0 23.0 165 KB

php-amqplib wrapper that eases the consumption of RabbitMQ. A painless way of using RabbitMQ

Home Page: https://packagist.org/packages/anik/amqp

License: MIT License

Dockerfile 0.69% PHP 99.14% Shell 0.17%
rabbitmq-consumer php-rabbitmq laravel-rabbitmq lumen-rabbitmq php-amqp php rabbitmq

amqp's Introduction

Hi, I am Syed Sirajul Islam

Open to REMOTE position

  • Backend engineer is the first priority. Full-stack otherwise.
  • Can overlap at least 4 hours in any timezone.
  • Reach out to me using this link

  • Prefered to be called by the name Anik (pronounced as aww-nick).
  • Currently employed at sender.net, as a senior software engineer.
  • Prevoiusly I worked for
  • Started as full time developer since 2016.
  • Writing codes in various languages since 2011.
  • I have been writing PHP since 2013 and Laravel since 2014.
  • I write APIs since 2016, and I am writing a lot since then.

Things I do & like

  • Whenever I find that there is no package available for what I'm doing, I write it of my own. Or write one if I think will help others.
  • Whenever I learn a new thing, I try to write articles on that topic. So that others can learn easily from my articles.
  • I write packages & articles which are free of all charges.
  • During my leisure time, I browse the internet and play Fifa online (I know I can't play 🙄) on my PS console.

Reach me out

Anik's liam Anik's Linkdein Anik's Medium Anik's Github Anik's Twitter Anik's dev.to

Languages & Tools

Either used in production or had hands on

Used or hands-on Down the pipeline
php laravel mysql postgresql git redis composer python javascript rabbitmq apache kafka docker terminal kubernetes graphql mercure vuejs css elasticsearch java css sass react nodejs elixir

GitHub Streak

Check my latest blog posts

... more blog posts on Medium

ssi-anik

amqp's People

Contributors

fosron avatar insanebits avatar paulredmond avatar peter279k avatar ryanhalliday avatar ssi-anik avatar steache avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

amqp's Issues

Queues are not being declared dynamically during publishing

Firstly, great work on the package and your detailed documentation.

Having an issue when publishing a message. Rabbit receives the message, the Exchange is declared / created, but the queue is not, and the message goes no where.

app('amqp')->publish('message', 'routing-key', [
        'exchange' => [
           'declare' => true,
           'name' => 'my_exchange',
           'type' => 'direct',
           'durable' => true,
           'auto_delete' => false,
           'internal' => false,
        ],
        'queue' => [
               'name' => 'queue_name',
               'declare' => true,
               'durable' => true,
               'auto_delete' => false,
               'd_properties' => [
                       'name' => 'queue_name,
                       'durable' => true,
                       'auto_delete' => false,
                ],
               'b_properties' => [
                       'source' => 'my_exchange',
                       'destination' => 'queue_name',
                       'destination_type' => 'queue',
                       'routing_key' => 'routing-key',
                ]
         ],
]);
  • config/amqp.php has defaults / has not been touched, though I have also tried placing these params in the queue configuration there, to no avail.
  • Rabbit user has all configure, write, read permissions
  • No error is thrown from this operation

Thanks in advance for taking a look.

How to keep the connection alive?

@ssi-anik is it possible to keep the connection alive,,

Currently, for each time we need to publish a new message to RabittMQ we need to make a new connection, it's very slow, is it possible to make the connection as a keepalive?

Support for AMQPStreamConnection

Not all AMQP / RabbitMQ servers have SSL setup (eg default Ubuntu apt install rabbitmq-server), so this package will fail with the vague error message of stream_socket_client(): unable to connect to ssl://localhost:5672.

Changing out AMQPSSLConnection for AMQPStreamConnection resolves this error - but there is no way to do this via configuration.

The RabbitMQ server logs don't help much either when debugging this, with only logs like 2020-XX-XX XX:XX:XX.XXX [error] <0.596.0> closing AMQP connection <0.596.0> (127.0.0.1:44504 -> 127.0.0.1:5672): {bad_header,<<22,3,1,2,0,1,0,1>>}

I suggest we include an option in the connection settings like:

'ssl' => env('AMQP_SSL', true),

Then we need to add a condition to AmqpManager->connect() to create either AMQPSSLConnection or AMQPStreamConnection.

If that sounds good to you @ssi-anik then I can make these changes and send a PR?

How to define multiple queues for consuming

Hello,

I'm using following code for consuming a queue:

$connection = $this->argument('connection') ?? config('amqp.default');
        app('amqp')->consume(function (ConsumableMessage $message) {
            $msg = json_decode($message->getStream(), true);
            $job = unserialize($msg['data']['command']);
            $throttleExceeded = $job->handle();
            if ($throttleExceeded === 'throttle exceeded')
            {
                $message->getDeliveryInfo()->reject(true);
            } else {
                $message->getDeliveryInfo()->acknowledge();
            }
        }, 'routing-key', [
            'connection' => $connection,
            'exchange' => [
                'type' => 'direct',
                'name' => $this->option('exchange'),
            ],
            'queue' => [
                'name' => $this->option('queue'),
                'declare' => true,
                'exclusive' => false,
            ],
            'qos' => [
                'enabled' => true,
                'qos_prefetch_count' => $this->option('prefetch_count'),
            ],
        ]);

I can run consume one queue without any issue. I want to consume multiple queues. How could I do so?

Testing in Laravel

Hey,

is there a way i can use this library in my feature tests in Laravel just like Queue::fake()?
If not, are there plans to implement it?

Thanks for your easy-to-use wrapper :)

Support for PHP 8

Currently only php 7 is supported and php-amqplib already seems to support php 8, so there shoudn't be any big issues with the upgrade.

EDIT:

It seems the issue is amqplib being locked at 2.9 which does not support PHP 8.

There was another related issue which was closed:

#16

Define queue as Quorum

Hi,

Would like to ask how to configure the queue type to quorum instead of classic. Currently using v1.6

Laravel 7 support?

Does this repo support Laravel 7? I'm looking to use with 7.19. Thanks.

Is it possible to add multiple bindings to a queue?

hi @ssi-anik, thank you for the nice package,

I am wondering if it is possible to add multiple bindings to a queue usgin the package?

from rabbitMq it is possible to add additional bindings to a queue, but the package only allow to add one binding.

Support for Laravel 6.x

Hello!
I was looking around for some way to use rabbitMQ with Laravel more conveniently way and found your repo!
I've tried to use it with Laravel 6.x but got a compatibility error, do you have any plans for this support?
"- anik/amqp v1.1 requires illuminate/container ^5.8"

Amqp connection [] is not defined on Lumen 6

Following the instructions of this article https://medium.com/@sirajul.anik/rabbitmq-for-php-developers-c17cd019a90.
Here is the Stack Trace

(1/1) InvalidArgumentException Amqp connection [] is not defined.

in AmqpManager.php line 64
at AmqpManager->resolve(null)in AmqpManager.php line 49
at AmqpManager->getConnection(null)in AmqpManager.php line 133
at AmqpManager->publish('Message to direct exchange', 'routing-key', array('exchange' => array('type' => 'direct', 'name' => 'direct.exchange')))in web.php line 20
at Closure->{closure}()
at call_user_func_array(object(Closure), array())in BoundMethod.php line 32
at BoundMethod::Illuminate\Container{closure}()in Util.php line 34
at Util::unwrapIfClosure(object(Closure))in BoundMethod.php line 78
at BoundMethod::callBoundMethod(object(Application), object(Closure), object(Closure))in BoundMethod.php line 34
at BoundMethod::call(object(Application), object(Closure), array(), null)in Container.php line 590
at Container->call(object(Closure), array())in RoutesRequests.php line 289
at Application->callActionOnArrayBasedRoute(array(true, array(object(Closure)), array()))in RoutesRequests.php line 263
at Application->handleFoundRoute(array(true, array(object(Closure)), array()))in RoutesRequests.php line 165
at Application->Laravel\Lumen\Concerns{closure}(object(Request))in RoutesRequests.php line 416
at Application->sendThroughPipeline(array(), object(Closure))in RoutesRequests.php line 171
at Application->dispatch(null)in RoutesRequests.php line 108
at Application->run()in index.php line 28

correlation_id and reply_to not working

Hello, I would like to ask if the following piece of code is correct Snímka obrazovky 2021-09-19 o 12 48 55

I am trying to implement the following
Snímka obrazovky 2021-09-19 o 12 50 34

It's working only in AMQP admin panel. I can see a published message in the exchange but I don't get response to queue called stefanTest.

Thank you for your help.

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.