npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rabbitmq-delete-message

v1.0.0

Published

A tool to delete a message from a queue in RabbitMQ

Downloads

62

Readme

RabbitMQ Delete Message

A tool to delete a specific message from a given queue in RabbitMQ.

:warning: This tool uses message property message_id to identify the message to delete.

This property has to be set by the client when pushing message to RabbitMQ.

Usage

npm i rabbitmq-delete-message

or

yarn add rabbitmq-delete-message
const deleteMessage = require('rabbitmq-delete-message');
const serverURL = 'amqp://localhost:15672';

deleteMessage(serverURL, 'MY_QUEUE', '6389503c-0281-412e-82cb-e92c97281b59')
  .then((response) => {
    if (response.deleted) {
      console.log('Message was deleted');
      console.log(response.message);
    } else {
      console.log('Message was not found');
    }
  })
  .catch((err) => console.log(err));

How it works

RabbitMQ does not provide any mechanism to delete a specific message within a queue, so this tool is a "workaround".

As mentionned in the introduction, the message_id property of a message has to be defined, and it has to be unique within all messages in the Queue, this id is defined by the producer of the message when pusshing it to RabbitMQ.

So now imagine we want to delete message with id 6389503c-0281-412e-82cb-e92c97281b59 from the queue MY_QUEUE.

First we create a new consumer for the queue MY_QUEUE, this consumer will create a new connection to the server, and a new channel.

So this consumer will consume all the messages of the queue, until it finds the message with the id 6389503c-0281-412e-82cb-e92c97281b59. When the message is found, the consumer, will acknowledge the message (to remove it from the queue) then stop and close the channel and resolve true (and the message).

If the current message is not the one to delete the message is nack in order to requeue it.

All messages message_id are stored to check if the consumer has read the message already, ie if we looped, if then the consumer will stop and close the channel and resolve false.

If one message has no message_id the promise is rejected, because it will not be possible to either check if we looped over all the messages, and because we can not match a specific message.

Configuration

You can change some configuration by setting those environment variables

  • RABBITMQ_DELETE_MESSAGE_TIMEOUT : The time after chanel is closed default is 1000 (milliseconds)
  • RABBITMQ_DELETE_MESSAGE_LOGLEVEL : Log level to display, see winston log levels, default is info
  • RABBITMQ_DELETE_MESSAGE_LOG_PREFIX : A Prefix for the logs, default is RABBITMQ_DELETE_MESSAGE

So you can override those values by setting environment variables.

License

MIT