Getting number of messages in a RabbitMQ queue

Using pika: import pika pika_conn_params = pika.ConnectionParameters( host=”localhost”, port=5672, credentials=pika.credentials.PlainCredentials(‘guest’, ‘guest’), ) connection = pika.BlockingConnection(pika_conn_params) channel = connection.channel() queue = channel.queue_declare( queue=”your_queue”, durable=True, exclusive=False, auto_delete=False ) print(queue.method.message_count) Using PyRabbit: from pyrabbit.api import Client cl = Client(‘localhost:55672’, ‘guest’, ‘guest’) cl.get_messages(‘example_vhost’, ‘example_queue’)[0][‘message_count’] Using HTTP Syntax: curl -i -u user:password http://localhost:15672/api/queues/vhost/queue Example: curl -i -u guest:guest http://localhost:15672/api/queues/%2f/celery Note: … Read more

RabbitMQ fails on Error: unable to connect to node rabbit@TPAJ05421843: nodedown

I had this same problem today. There were no cookie or firewall problems and windows reported that the service was running successfully. This is what finally fixed it: Run RabbitMQ sbin command prompt as administrator. Run “rabbitmq-service remove” Run “rabbitmq-service install” For some reason the service set up by the installer did not configure several … Read more

How to add initial users when starting a RabbitMQ Docker container?

You can create a simple Dockerfile that extends the functionality of the basic image and creates a default user. The Docker file you need is the following: FROM rabbitmq # Define environment variables. ENV RABBITMQ_USER user ENV RABBITMQ_PASSWORD user ENV RABBITMQ_PID_FILE /var/lib/rabbitmq/mnesia/rabbitmq ADD init.sh /init.sh RUN chmod +x /init.sh EXPOSE 15672 # Define default command … Read more

Is there a performance difference between pooling connections or channels in rabbitmq?

I have found this on the rabbitmq website it is near the bottom so I have quoted the relevant part below. The tl;dr version is that you should have 1 connection per application and 1 channel per thread. Connections AMQP connections are typically long-lived. AMQP is an application level protocol that uses TCP for reliable … Read more

Spring RabbitMQ – using manual channel acknowledgement on a service with @RabbitListener configuration

Add the Channel to the @RabbitListener method… @RabbitListener(queues = “${eventqueue}”) public void receiveMessage(Order order, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) throws Exception { … } and use the tag in the basicAck, basicReject. EDIT @SpringBootApplication @EnableRabbit public class So38728668Application { public static void main(String[] args) throws Exception { ConfigurableApplicationContext context = SpringApplication.run(So38728668Application.class, args); context.getBean(RabbitTemplate.class).convertAndSend(“”, “so38728668”, “foo”); … Read more

Spring AMQP + RabbitMQ 3.3.5 ACCESS_REFUSED – Login was refused using authentication mechanism PLAIN

I am sure what Artem Bilan has explained here might be one of the reasons for this error: Caused by: com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED – Login was refused using authentication mechanism PLAIN. For details see the but the solution for me was that I logged in to rabbitMQ admin page (http://localhost:15672/#/users) with the default user name and … Read more

Handling long running tasks in pika / RabbitMQ

For now, your best bet is to turn off heartbeats, this will keep RabbitMQ from closing the connection if you’re blocking for too long. I am experimenting with pika’s core connection management and IO loop running in a background thread but it’s not stable enough to release. In pika v1.1.0 this is ConnectionParameters(heartbeat=0)