I am using rabbitmq, and I try to purge a queue by using commands like below:
[root#test xxx]# rabbitmqctl purge_queue metering.sample
Purging queue 'metering.sample' in vhost '/' ...
[root#test xxx]# rabbitmqadmin purge queue
name=metering.sample
queue purged
[root#test xxx]# rabbitmqctl list_queues | grep sample
metering.sample 17172
Initially, the queue was filled with 296533 messages, after I ran both of the commands, the queue is still filled with 17172 messages. (I am sure there is no publisher running anymore)
why did it happen? is it a bug or I used it by wrong way?
need some help, thanks in advance.
Keep in mind that the unacked messages are not purged by those commands.
https://stackoverflow.com/a/25116528/2047138
Related
I have referred the link https://www.rabbitmq.com/lazy-queues.html here and set the rabbitmq queue to lazy queue using the following command
rabbitmqctl set_policy Lazy "^lazy-queue$" '{"queue-mode":"lazy"}' --apply-to queues
However, when checking it using the command curl -u guest:guest 'localhost:15672/api/queues' it still shows the default queue as below
"mode":"default" .
How do I set the queue to lazy queue in rabbitmq. Could someone please help
A Policy defines a rule that applies to all queues whose name matches a particular pattern.
Let's have a closer look at the command you've copied:
rabbitmqctl set_policy Lazy "^lazy-queue$" '{"queue-mode":"lazy"}' --apply-to queues
We are creating or updating a policy called "Lazy"; as far as I know, this can be any name you like
The pattern we want it to apply to is ^lazy-queue$; this is a regular expression which only matches the exact name "lazy-queue"
The configuration we want to apply is to set "queue-mode" to "lazy"
So, if you want it to apply to multiple queues, you need to adjust the policy to apply to those queues. For instance, you could apply it to all queues whose names begin "lazy-":
rabbitmqctl set_policy Lazy "^lazy-" '{"queue-mode":"lazy"}' --apply-to queues
Or any name that ends in a four-digit number:
rabbitmqctl set_policy Lazy "-[0-9]{4}$" '{"queue-mode":"lazy"}' --apply-to queues
Or just apply to every queue:
rabbitmqctl set_policy LazyEverything ".*" '{"queue-mode":"lazy"}' --apply-to queues
I want to fetch the last / latest message added in the queue, is there a specific option available in the rabbitmqadmin utility.
The following command is giving the first message in the queue,
./rabbitmqadmin get queue='log' -H localhost -P 15672 -u <username> -p <password> --vhost=logging count=1
Are you looking to consume or view the messages? I use this tool plumber to view the latest incoming messages without removing them from the queue. If you are looking to consume just the latest message you may have to write a script.
To read the latest inbound message and exit:
plumber read messages rabbitmq --address amqp://user#pass:127.0.0.1:5672 --exchange events --routing-key \#
To watch all messages as they come in:
plumber read messages RabbitMQ --address amqp://user#pass:127.0.0.1:5672 --exchange events --routing-key \# --follow
If you use plumber your queue must be set up on its own exchange you can not use the RabbitMQ default exchange see.
Not able to update existing TTL for particular Queue
Got some command but it will be for all queue.
rabbitmqctl set_policy TTL ".*" '{"message-ttl":60000}' --apply-to queues
I need to update only for one Queue. Please help
I want to get alert in mail when Apache Kafka and Apache Zookeeper process get stopped and when it get stopped it automatically restart both of them. Neither Apache Kafka and Apache Zookeeper does not create any pid file nor it comes under init script.
My monit control files for Apache Zookeeper and Apache Kafka is defined below
check process zookeeper match "config/zookeeper.properties"
if not exist then exec "/Users/xxxx/kafka_2.10-0.9.0.1/bin/zookeeper-server-start.sh -c -d config/zookeeper.properties" and alert xxxx#gmail.com with reminder on 500 cycles
check process kafka match "config/server.properties"
if not exist then exec "/Users/xxxx/kafka_2.10-0.9.0.1/bin/kafka-server-start.sh -c -d config/server.properties" and alert xxxx#gmail.com with reminder on 500 cycles
When I reload and start monit, it gives an error of 'kafka' process is not running and 'zookeeper' process is not running.
Please help me how to restart a Kafka and Zookeeper process and get an alert of mail
First of all, it's "matching", not "match".
Secondly, your regex pattern will not work. You can test the pattern using
monit procmatch "regex-pattern"
This will tell you if the matching works.
Thirdly, use "start program", "stop program" to start/stop kafka.
Here's an example of my monit:
check process kafka matching "java -Xmx1G.*kafka"
start program "/bin/bash -c 'cd /usr/local/xxx/kafka_2.10-0.8.2.1/; bin/kafka-server-start.sh config/server.properties &'"
stop program "/bin/bash -c 'cd /usr/local/xxx/kafka_2.10-0.8.2.1/; bin/kafka-server-stop.sh'"
alert xxxx#gmail.com with reminder on 500 cycles
I have master-slave configuration of RabbitMQ. As two Docker containers, with dynamic internal IP (changed on every restart).
Clustering works fine on clean run, but if one of servers got restarted it cannot reconnect to the cluster:
rabbitmqctl join_cluster --ram rabbit#master
Clustering node 'rabbit#slave' with 'rabbit#master' ...
Error: {ok,already_member}
And following:
rabbitmqctl cluster_status
Cluster status of node 'rabbit#slave' ...
[{nodes,[{disc,['rabbit#slave']}]}]
says that node not in a cluster.
Only way I found it remove this node, and only then try to rejoin cluster, like:
rabbitmqctl -n rabbit#master forget_cluster_node rabbit#slave
rabbitmqctl join_cluster --ram rabbit#master
That works, but doesn't look good for me. I believe there should be better way to rejoin cluster, than forgetting and join again. I see there is a command update_cluster_nodes also, but seems that this something different, not sure if it could help.
What is correct way to rejoin cluster on container restart?
I realize that this has been opened for a year but I though I would answer just in case it might help someone.
I believe that this issue has been resolved in a recent RabbitMQ release.
I implemented a Dockerized RabbitMQ Cluster using the Rabbit management 3.6.5 image and my nodes are able to auto rejoin the cluster on container or Docker host restart.