How in RabbitMQ and PHP do task one by one? - rabbitmq

How do RabbitMQ taks perform one after another Not all the same time,
e.g.
We have 10 task that follow each other.
Task 1 end do task 2 etc..

The RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.
Set your channel's prefetch (QoS) value to 1. Then, when you consume messages, RabbitMQ will only send one message and will not send more until that one message is acknowledged.
I suggest that you do all of the RabbitMQ tutorials, especially this one.

Related

Set minimum delay between message - rabbitmq

I need a solution where I can set a minimum delay between the messages that are polled out of the Queue. I do not want to delay every message by a fixed amount of miliseconds.
Lets say the Queue get 3 messages in the first second. But I want to pull every 5 seconds. So my Client does not get overloaded with to many request.
Is there a way to solve this with rabbitmq or do i have to change to some other framework?
Any time you ask for assistance about RabbitMQ (or any software), you must provide information about what versions of software you are using, and what client libraries. That way the people who are assisting you can do so effectively.
Your client should consume from the queue using the basic.consume method. Set the channel's "prefetch" value to the maximum number of unacknowledged messages you wish for that consumer to receive at once (you can set it to 1 if you only want one message at a time). Then, do your work and only acknowledge the messages after the desired amount of time has elapsed.
Be certain that this does not result in messages accumulating in queues. You will monitor your RabbitMQ installation, right?
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

RabbitMQ and FIFO when multiple consumers

We have multiple consumer to handle create messages, but we want to ensure the FIFO order so if we create a product A, we must to reject the next creations of product A.
The problem is because we have several consumers to treate this type of messages it is possible to have consumer 1 that finish after consumer 2. For exemple the message 1 contains more data to be saved compared to mesage 2 for the same product.
Running RabbitMQ with multiple consumers violates FIFO principle of queue. Is there a way to avoid this with RabbitMQ or we must to orientate our architecture in a manner that the control is more Java threatement oriented ?
Thanks
Running RabbitMQ with multiple consumers violates FIFO principle of
queue.
No, it doesn't. The messages are delivered in FIFO order. Multiple consumers will result in messages being delivered round-robin among them, but they are still delivered in FIFO order.
If you want to retain this order, you must use only one consumer, or coordinate work between your consumer processes.
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

RabbitMQ guarantee delivery to mirrored queue

Assume I have a mirrored queue deployed over multiple nodes (f.e. 1 master + 1 mirror). I can define the number of mirrors I want but is it possible to only accept a producer message when the message is stored at least on 2 queues (master + mirror). Otherwise it is still possible to loose a message when the master node fails before the message is mirrored.
So the mirroring activity should be part of the transaction.
You should use Publisher Confirms. When this is enabled, and your publisher has received confirmation, you can be certain that your message has been replicated to all queue mirrors.
Searching Google for site:rabbitmq.com high availability returns this document which mentions Publisher Confirms here.
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

Is there a way to set a TOTAL message number limit in a RabbitMQ queue? x-max-length doesn't take into account the unacked messages

I need a queue with limited message inside considering not only message in queue but also the unacked ones. Is there a way to configure this server side? If yes is it possible using kobu as library?
Thank you
The RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.
The documentation clearly states that queue length uses the count of ready messages: https://www.rabbitmq.com/maxlength.html

RabbitMQ Work Queue Configuration Questions

I have two questions about RabbitMQ Work Queues:
As I understand it from the RabbitMQ tutorials, it seems that if I have a basic queue consumer client (just a basic "Hello, World!" consumer) and then I add a second consumer client for the same queue, then RabbitMQ will automatically dispatch the messages between those two queues in a round robin manner. Is that true (without adding in any extra configuration)?
My consumer clients are configured to only ever receive one message at a time, using (GetResponse response = channel.basicGet("my_queue", false). Since I am only ever receiving one message at a time, is it still necessary to set a prefetchCount (channel.basicQos(1)) for fair dispatch?
Answers to your questions:
Yes
No
However, your two questions 1 and 2 are not compatible. If you are using a consumer, it is designed to have messages pushed to it, and you don't use Basic.Get. When you use a consumer, you will need to use Basic.QoS to specify that the consumer can only "own" one unacknowledged message at a time. RabbitMQ will not push additional messages beyond the QoS limit.
Your alternative is to "pull" from the queue using Basic.Get, and you will control your own destiny as far as how many messages you run at a time.
Does this make sense?