Giter Site home page Giter Site logo

rlg2161 / rabbitmq-dump-queue Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dubek/rabbitmq-dump-queue

0.0 2.0 0.0 6 KB

Dump messages from a RabbitMQ queue to files, without affecting the queue.

License: MIT License

Go 81.00% Shell 19.00%

rabbitmq-dump-queue's Introduction

rabbitmq-dump-queue

Dump messages from a RabbitMQ queue to files, without affecting the queue.

Installation

Download a release

Precompiled binary packages can be found on the releases page.

Compile from source

If you have Go installed, you can install rabbitmq-dump-queue from source by running:

go get github.com/dubek/rabbitmq-dump-queue

The rabbitmq-dump-queue executable will be created in the $GOPATH/bin directory.

Usage

To dump the first 50 messages of queue incoming_1 to /tmp:

rabbitmq-dump-queue -uri="amqp://user:[email protected]:5672/" -queue=incoming_1 -max-messages=50 -output-dir=/tmp

This will create the files /tmp/msg-0000, /tmp/msg-0001, and so on.

The output filenames are printed one per line to the standard output; this allows piping the output of rabbitmq-dump-queue to xargs or similar utilities in order to perform further processing on each message (e.g. decompressing, decoding, etc.).

Running rabbitmq-dump-queue -help will list the available command-line options.

Message requeuing implementation details

In order to fetch messages from the queue and later return them in the original order, rabbitmq-dump-queue uses a standard AMQP basic.get API call without automatic acknowledgements, and it doesn't manually acknowledge the received messages. Thus, when the AMQP connection is closed (after all the messages were received and written to files), RabbitMQ returns all the un-acked messages (all the messages) back to the queue in their original order.

This means that during the time rabbitmq-dump-queue receives and saves the messages, the messages are not visible to other consumers of the queue. This duration is usually very short (unless you're downloading a lot of messages), but make sure your system can handle such a situation (or shut down other consumers of the queue during the time you use this tool).

Note that the same approach is used by RabbitMQ's management HTTP API (the /api/queues/{vhost}/{queue}/get endpoint with requeue=true).

Contributing

Github pull requests and issues are welcome.

License

rabbitmq-dump-queue is under the MIT License. See the LICENSE file for details.

rabbitmq-dump-queue's People

Contributors

dubek avatar kruppel avatar sshaw avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.