S
S
Stan_12014-08-22 11:07:11
RabbitMQ
Stan_1, 2014-08-22 11:07:11

How to properly work with RabbitMQ channels?

Good afternoon!
It looks like I don't understand something fundamentally, please point me in the right direction.
There is PO1 and PO2 that communicate via RabbitMQ. PO1 does create_channel, puts the message in the queue, closes the channel.
Then software2 is launched by the crown, which does create_channel, reads the message, closes the channel.
This scheme stops working when there is a large flow of messages from PO1. Experimentally, it was found out that when I create a create_channel from software, and at the same time in another software there is already an established connection at that moment, the earlier channel stops working (it is reinstalled with the removal of accumulated messages) and the messages in it are lost.
As a result, out of eg 400 messages that arrive within 3 seconds, about 5-6 messages are lost randomly.
How to properly organize the work of two scripts that are launched randomly? Is it possible in RabbitMQ not to create a channel again, but to use an existing one if it exists, and create it only when it exists or closes?
Thanks in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Intentio, 2014-10-23
@Intentio

Channel is the object through which the interaction with the RabbitMQ server takes place.
The documentation says that you need to use one Channel in one stream. If you use the same Channel in multiple threads, then this can lead to errors.
In your case, there is a possibility that at the time of creating the Channel, the queue is recreated and all messages are lost, i.e.:

$channel->queue_declare('hello', false, false, false, false);

T
tegrato, 2018-07-12
@tegrato

Why and how do you create a channel?
In theory, it doesn't need to be done at all. Rabbit supports automatic channel management - he creates and closes himself. Accordingly, with the simultaneous operation of 2 programs, it will use different channels for one queue, and nothing will be lost.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question