Queues are getting deleted in RabbitMQ - rabbitmq

So I created some queues with the command below...
rabbitmqadmin --vhost=blocking-mq declare queue name="data-api-queue" durable=true auto_delete=false 'arguments={"x-message-ttl":1200000,"x-expires":1200000}'
rabbitmqadmin --vhost=blocking-mq declare queue name="interaction-api-queue" durable=true auto_delete=false 'arguments={"x-message-ttl":1200000,"x-expires":1200000}'
rabbitmqadmin --vhost=blocking-mq declare queue name="realtime-api-queue" durable=true auto_delete=false 'arguments={"x-message-ttl":1200000,"x-expires":1200000}'
rabbitmqadmin --vhost=blocking-mq declare queue name="blocking-api-queue" durable=true auto_delete=false 'arguments={"x-message-ttl":1200000,"x-expires":1200000}'
But after restarting my machine I see that they are deleted. I created them again and restarted and that occurred again. But exchange declared in a same-ish manner(with rabbitmqadmin) persisted and also queues of the other vhost are still there too...
N.B. The persisting queues of the other vhost was created via the management panel.
How to solve this issue(without declaring queues after every reboot)...???

Team RabbitMQ provided an answer here:
https://github.com/rabbitmq/rabbitmq-server/discussions/6751
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

Related

ActiveMQ - how to set persistency from config?

I have a topic and three queues in activeMQ. Producer is publishing the message to the topic and it's routing the same message in these three queues. Now my question is:
I haven't set persistency in producer and I don't want to because of some project limitation. How caan I set persistency for the topic and queues from ActiveMQ broker? I am using ActiveMQ 5.15.12 version.
Can I set persistency for one queue and don't set for another?
What will happen if I don't use the persistency? I know there have chances of losing messages during broker restart but is there any other way to overcome this issue?

Rabbitmq x-overflow reject-publish does not work when set via web console

I'm trying to set the overflow behavior of a particular queue in the Rabbitmq to reject messages exceeding the max limit. I'm using the web console to add a new queue and set the x-max-length. Then I manually added x-overflow and gave it the value of reject-publish. But it seems the default overflow behavior is the one that is getting applied, where the older messages are removed and new ones are enqueued.
Is the way I'm defining the overflow behavior wrong? Could someone please point me how I should be setting the overflow behavior via the web console?
Its not work via web gui, only through cli.
Example:
rabbitmqctl set_policy limit-1gb ".*" '{"max-length-bytes":1000000000,"overflow":"reject-publish"}' --apply-to queues
rabbitmqctl set_policy limit-1m ".*" '{"max-length":1000000,"overflow":"reject-publish"}' --apply-to queues
The x-overflow option is only available for classic queues and NOT quorum queues. So if you were using quorum queue this is the explanation.
Currently (in Rabbit 3.8.5) the quorum queue only supports drop-head overflow, and not reject-publish or reject-publish-dlx.

How to copy messages to another queue on RabbitMQ?

Using RabbitMQ as broker, I would like to copy all the messages from one queue to another queue for test/debug purpose. What's the simplest way via RabbitMQ web management console / cli?
P.S. Under web console for specified queue, I could only Move messages instead of Copy messages to new queue.
When I need to perform such tasks, I do as follows (assuming you want to copy all of the messages from your reference queue):
create a fanout exchange or use the default one (amq.fanout) if he isn't bound to any queue
bind the reference queue to it
bind the "duplicate" queue to it
configure a shovel to send all the messages in the reference queue to the exchange you bound to both queues, with auto-delete set to "After initial length transferred"
But it does mean that if messages arrived to the reference queue through it's normal flow, they will end up at the top of the queue, with the "copied" messages behind/mixed with them
just create another queue with the same routing key if the exchange is a direct exchange
Go to http://localhost:15672/#/queues
Create vhost (vhost=testhost)
Create two queue using vhost( Test1, Test2)
Create exchange Test_exchange: http://localhost:15672/#/exchanges
Bind these queue(Test1 & Test2) on Test_exchange
Install shovel
sudo rabbitmq-plugins enable rabbitmq_shovel
sudo rabbitmq-plugins enable rabbitmq_shovel_management
Add shovel using admin shovel tab
URI: amqp://{user}:{pass}#{localhost}:5672/vhost (this is for reference queue which u want to create copy, vhost if it has)
source
Destination URI: amqp://user:pass#localhost:5672/Test_exchnage
Queue Name: “Test_exchange”
You can can send msg to your reference queue.
There's a commercial tool, QueueExplorer (disclaimer - I'm the author) which allows you to copy messages, among other things.

rabbitmq-server start losing data over durable queues

On windows, when I am using rabbitmq-server start/stop commands, data over the RabbitMQ durable queues are deleted. It seems queues are re-created when I start the RabbitMQ server.
If I use rabbitmqctl stop_app/start_app, I am not losing any data. Why?
What will happen if my server goes down and how can I be sure I that I won't lose data if it does?
configuration issue: I was starting rabbitmq from rabbitmq sbin directory. I re-installed the rabbitmq and added rabbitmq to windows services. Now data lost problem was solved on my computer. When I start/stop the windows service , rabbitmq is not losing any data
Making queues durable is not enough. Probably you'll need also to declare exchange as durable as well as send 'persistent' messages.
In Java you'll use:
channel.basicPublish("", "sample_queue",
MessageProperties.PERSISTENT_TEXT_PLAIN, // note that this parameter is not null!
message.getBytes())

How can I delete a RabbitMq exchange?

I can easily delete queues, like this:
rabbitmqadmin delete queue name='MyQ'
However, I cannot find a way to delete exchanges. What am I missing?
➜
./rabbitmqadmin delete exchange name='myexchange'
exchange deleted
you can also get the same functionality with the rabbitmq management web interface,
usually accessible via localhost:15672
(the rabbitmq management plugin need to be installed, usually the case)