-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AMQP Adapter #32
Comments
Relates to #8. Thanks for posting your progress so far @stevenscg, it's great to understand your thinking before a PR comes along. I'll make sure to have a good read of videlalvaro/php-amqplib. Would you mind linking to where |
Yup. This library is used for the official RabbitMQ tutorials: While AMQP can work in a number of interesting and useful queuing scenarios, I almost always end up back with simple work queues where I can run N producers and consumers to load balance and parallelize work. Basic "consume" vs "get":
|
Brilliant, thanks very much for the reading material 👓! |
This is just a placeholder for discussion regarding a new AMQP adapter (RabbitMQ, etc).
I did some prototyping of a new adapter using the SqsAdapter as a baseline and my preferred library (one of the best AFAIK): https://github.com/videlalvaro/php-amqplib.
I was able to
enqueue
anddequeue
the messages rather easily, but have had trouble withacknowledge
thus far. I'll continue to work on that and link to it when I have something functional.The AMQP library recommends that consumers use
$channel->basic_consume()
.https://github.com/videlalvaro/php-amqplib/blob/master/PhpAmqpLib/Channel/AMQPChannel.php#L898
This works by declaring a callback and the consumer will remain attached and receiving messages as long as the callback is registered.
The core logic looks roughly like this:
I have not yet been able to
dequeue
using the abovebasic_consume
logic which I think will be the best long-term approach for this new adapter. I'll circle back to this after I can getacknowledge
working.However, I was able to get the
$channel->basic_get()
operation to work within a loop yielding$factory->createMessage()
items.https://github.com/videlalvaro/php-amqplib/blob/master/PhpAmqpLib/Channel/AMQPChannel.php#L981
The AMQP library doesn't recommend this due to inefficiencies (etc), but I have seen their maintainers suggest this method as an option for people trying to build their own blocking consumers.
A third option is also a possibility:
$channel->batch_basic_publish()
https://github.com/videlalvaro/php-amqplib/blob/master/PhpAmqpLib/Channel/AMQPChannel.php#L1115
I haven't used it myself and didn't know it was even available until last week.
The text was updated successfully, but these errors were encountered: