I
I
igordata2015-07-01 20:19:37
PHP
igordata, 2015-07-01 20:19:37

ReactPHP + RabbitMQ how to do a non-blocking wait for a new message?

Good day to all.
Actually a question. I decided to make posts on the site on ReactPHP + RabbitMQ hoping for asynchrony in long pooling. But in fact, PhpAmqpLib uses a blocking wait. Can someone tell me how to wait and not be blocked?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ramoder, 2015-07-16
@Ramoder

I didn’t quite understand about PhpAmqpLib blocking waits, in the amqp extension for php there is quite a non blocking get method. It seems to me that phpdaemon is
suitable for your task . Of course, you will also have to use timers (asynchronous timers are implemented in phpdaemon via libevent), or wait until the amqp protocol is implemented for it . Plus, everything is perfectly parallel due to the asynchronous operation of the framework.

I
Igor Rusinov, 2015-07-09
@RusinovIG

What do you mean by non-blocking wait? If you connected - checked messages - disconnected - then this suggests that such an operation needs to be performed with a certain frequency, then the meaning of RabbitMQ in this scenario is lost, because it is possible to check new messages at once in a DBMS after a certain interval of time for example.
As for messages and RabbitMQ, you can create 2 queues, (one for sending messages, the other for receiving). Accordingly, to receive messages, we connect to the queue, listen to messages from it and, upon receipt, issue it to the user. To send messages, we send a separate request in the second queue, there will be no blocking here.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question