Rabbitmq queue mirroring policy don't work when TTL policy is added to the cluster

294 views
Skip to first unread message

qrshat

unread,
Oct 10, 2022, 7:52:25 PM10/10/22
to rabbitmq-users
0

On a five nodes rabbitmq cluster,I created two policies. One is for queue replication and the other is for TTL poliecs.

When I create a queue replication policy with the below commands, It works successfully, without any error.

rabbitmqctl set_policy ha-three .replica. '{"ha-mode":"exactly","ha-params":2,"ha-sync-mode":"automatic"}'

After creating the queue replication policy, I added a TTL policy with the below command. But when I add the TTL policy, the queue replication policy lost its functionality and don't work. When I remove the TTL leave policy, the replication policy starts to work properly again.

rabbitmqctl set_policy TTL ".*" '{"message-ttl":3600000}' --apply-to queues

I don't understand why TTL policy affects the queue replication policy. Did I miss something? I want two policies are working on the same cluster without effecting each other.

Luke Bakken

unread,
Oct 10, 2022, 8:06:35 PM10/10/22
to rabbitmq-users
Hello,

Only one policy at a time can be active for a queue. When you add your second policy, it matches all queues and probably is the one being applied.

If you want have your ha-three policy take precedence, give it a higher priority via the --priority argument - 

If you want to have both TTL and ha-three apply to a queue, you'll have to create a new policy that combines the two and assign it the correct regex and priority to be applied.

Thanks,
Luke

qrshat

unread,
Oct 13, 2022, 4:03:31 AM10/13/22
to rabbitmq-users
Thanks Luker, I appreciate your answer.  I've created a combined policy and it works perfectly. 

qrshat

unread,
Oct 18, 2022, 5:04:26 PM10/18/22
to rabbitmq-users
Hi All,

When I set the below combined policy, It works fine.

# rabbitmqctl set_policy ha-three-TTL test  '{"ha-mode":"exactly","ha-params":3,"ha-sync-mode":"automatic","message-ttl":3600000}'

When I set the below policies, they also work fine.

# rabbitmqctl set_policy test_TTL .*test.* '{"message-ttl":3600000}' --apply-to queues --priority 44
 # rabbitmqctl set_policy test_TTL_SMS .*test.Sms.* '{"message-ttl":18000000}' --apply-to queues --priority 51
 # rabbitmqctl set_policy test_TTL_Mail .*test.Mail.* '{"message-ttl":18000000}' --apply-to queues --priority 52
 # rabbitmqctl set_policy test_TTL_ServiceLog .*test.ServiceLog.* '{"message-ttl":86400000}' --apply-to queues --priority 58 

But when I set the below policies, they don't work as I expected. TTL policies didn't clear the queue for the test queue and test Sms queue and so. 

 # rabbitmqctl set_policy ha-three-test_TTL   .*test.*  '{"ha-mode":"exactly","ha-params":3,"ha-sync-mode":"automatic","message-ttl":3600000}' --apply-to queues --priority 44
 # rabbitmqctl set_policy ha-three-test_TTL_SMS  .*test.Sms.*   '{"ha-mode":"exactly","ha-params":3,"ha-sync-mode":"automatic","message-ttl":18000000}' --apply-to queues --priority 52
  # rabbitmqctl set_policy ha-three-test_TTL_Mail  .*test.Mail.*   '{"ha-mode":"exactly","ha-params":3,"ha-sync-mode":"automatic","message-ttl":18000000}' --apply-to queues --priority 52
  # rabbitmqctl set_policy ha-three-test_TTL_ServiceLog  .*test.ServiceLog.*   '{"ha-mode":"exactly","ha-params":3,"ha-sync-mode":"automatic","message-ttl":86400000}' --apply-to queues --priority 58

 
I don't understand the reason of why the policies don't work as my expectations. Is there  anyone who know how I should set the policies. I just want queue replication policies and TTL policies to work together according to the priority I set.
I googled a lot, but didn't find any solid solution to that.

Thanks in advance

Luke Bakken

unread,
Oct 18, 2022, 7:22:39 PM10/18/22
to rabbitmq-users
You should run rabbitmqctl report and be 100% sure the policy you expect is being applied to the queue you expect.

kjnilsson

unread,
Oct 19, 2022, 3:52:10 AM10/19/22
to rabbitmq-users
Not to do with policies but just to make sure you are aware that HA classic queues are deprecated in favour of quorum queues and if this is a new system you are configuring I would recommend moving to quorum queues instead (also you don't need an HA policy for them as they are inherently HA)

qrshat

unread,
Oct 31, 2022, 11:53:18 AM10/31/22
to rabbitmq-users
Very thanks Kjnilsson.Luker.  I start to use quorum queues instead of classic. All the policies are started to work properly.  But,  after using quorum queues,  I observed that producer services feed the queues slower than classic queues. Is that normal or do I miss any configuration that results this performance issue?

kjnilsson

unread,
Nov 1, 2022, 5:29:59 AM11/1/22
to rabbitmq-users
As a general rule QQs tend to have better throughput than _mirrored_ classic queues but higher latency than non mirrored classic queues (v2). So if you wait for publisher confirms after each message send operation it may seem slower.

kjnilsson

unread,
Nov 1, 2022, 5:30:59 AM11/1/22
to rabbitmq-users
Also if you use a new channel for each publish it will definitely be slower. QQs are optimised for long running connections / channels.
Reply all
Reply to author
Forward
0 new messages