Bootstrap FreeKB - RabbitMQ - Delete dynamic shovel using src-delete-after parameter
RabbitMQ - Delete dynamic shovel using src-delete-after parameter

Updated:   |  RabbitMQ articles

A shovel is used to move a message from a queue or exchange to a different queue or exchage. The queues or exchanges can reside on the same RabbitMQ node or on different RabbitMQ nodes.

 

AVOID TROUBLE

There are two types of shovels.

Only a dynamic shovel can be deleted using the rabbitmqctl clear_parameter command.

 

The src-delete-after parameter can be used to delete a dynamic shovel when:

  • The queue-length of the source queue will be measure, which is the count of messages in the queue, and the shovel will be deleted after the queue length has been reached.
  • The shovel will be deleted after "x" messages have been moved, where "x" is an integer value.

The src-delete-after parameter defaults to never, meaning that a shovel will not be automatically deleted.


queue-length

Let's say you use the rabbitmqctl set_parameter command to create a shovel named shove001 in the foo virtual host, to move messages from a.queue to b.queue. In this example, queue-length is used.

If there are 10 messages in a.queue, then the shovel will be deleted once all 10 messages have been moved to b.queue.

rabbitmqctl set_parameter shovel shovel001 
'{
  "src-uri": "amqp:///foo",
  "src-queue": "a.queue",
  "src-delete-after": "queue-length",
  "dest-uri": "amqp:///foo",
  "dest-queue": "b.queue"
}'
--vhost foo

 


custom integer

Let's say you use the rabbitmqctl set_parameter command to create a shovel named shove001 in the foo virtual host, to move messages from a.queue to b.queue. In this example, src-delete-after: 1 is used, meaning that the shovel will be deleted after 1 messages is moved from a.queue to b.queue.

rabbitmqctl set_parameter shovel shovel001 
'{
  "src-uri": "amqp:///foo",
  "src-queue": "a.queue",
  "src-delete-after": 1,
  "src-prefetch-count": 1,
  "dest-uri": "amqp:///foo",
  "dest-queue": "b.queue"
}'
--vhost foo

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter d3976e in the box below so that we can be sure you are a human.