EzDevInfo.com

rabbitmq interview questions

Top rabbitmq frequently asked interview questions

How to delete all the queues from Rabbitmq?

I installed rabbitmqadmin and was able to list all the exchanges and queues. How can I use rabbitmqadmin or rabbitmqctl to delete all the queues.


Source: (StackOverflow)

Whats the advantage of using celery with rabbitmq over Redis, MongoDB or Django ORM)

Is there a speed advantage, functionality advantage?

Also using Django ORM (mysql), is it a lot slower than using rabbitmq, mongodb or redis?

Im currently hosting on webfaction, and installing erland and rabbit is both complicated, and from comments i read takes quite a bit of ram, so would just running celery with database be a smarter option? why or why not?


Source: (StackOverflow)

Advertisements

Deleting queues in rabbitmq

I have a few queues running with RabbitMq. A few of them are of no use now, how can I delete them? Unfortunately I had not set the auto_delete option.

If I set it now, will it be deleted?

Is there a way to delete those queues now?

Thanks!


Source: (StackOverflow)

RabbitMQ message size and types

  1. What messages could be stored in RabbitMQ queues? Only strings? Or can I select what type I want to store: int, binary, string etc.?
  2. What is the max size of one message?
  3. How many queues or exchanges could be created? Or does it depend on the server's power?

Thanks for your time.


Source: (StackOverflow)

Comparison between RabbitMQ and MSMQ

Can I get the comparison between RabbitMQ and MSMQ. It will be helpful performance information on different factors are available.


Source: (StackOverflow)

Why use AMQP/ZeroMQ/RabbitMQ

as opposed to writing your own library.

We're working on a project here that will be a self-dividing server pool, if one section grows too heavy, the manager would divide it and put it on another machine as a separate process. It would also alert all connected clients this affects to connect to the new server.

I am curious about using ZeroMQ for inter-server and inter-process communication. My partner would prefer to roll his own. I'm looking to the community to answer this question.

I'm a fairly novice programmer myself and just learned about messaging queues. As i've googled and read, it seems everyone is using messaging queues for all sorts of things, but why? What makes them better than writing your own library? Why are they so common and why are there so many?


Source: (StackOverflow)

What ports does RabbitMQ use?

What ports does RabbitMQ Server use or need to have open on the firewall for a cluster of nodes?

My /usr/lib/rabbitmq/bin/rabbitmq-env is set below which I'm assuming are needed (35197).

SERVER_ERL_ARGS="+K true +A30 +P 1048576 \   
-kernel inet_default_connect_options [{nodelay,true}] \  
-kernel inet_dist_listen_min 35197 \   
-kernel inet_dist_listen_max 35197"

I haven't touched the rabbitmq.config to set a custom tcp_listener so it should be listening on the default 5672.

Here are the relevant netstat lines:

tcp        0      0 0.0.0.0:4369           0.0.0.0:*           LISTEN      728/epmd 
tcp        0      0 0.0.0.0:35197          0.0.0.0:*           LISTEN      5126/beam
tcp6       0      0 :::5672                :::*                LISTEN      5126/beam

My questions are:

  1. for other nodes to be able to connect to the cluster, do all 3 ports 4369, 5672 and 35197 need to be open?

  2. Why isn't 5672 running on tcp and not just tcp6?


Source: (StackOverflow)

Performance comparison between ZeroMQ, RabbitMQ and Apache Qpid

I need a high performance message bus for my application so I am evaluating performance of ZeroMQ, RabbitMQ and Apache Qpid. To measure the performance, I am running a test program that publishes say 10,000 messages using one of the message queue implementations and running another process in the same machine to consume these 10,000 messages. Then I record time difference between the first message published and the last message received.

Following are the settings I used for the comparison.

  1. RabbitMQ: I used a "fanout" type exchange and a queue with default configuration. I used the RabbitMQ C client library.
  2. ZeroMQ: My publisher publises to tcp://localhost:port1 with ZMQ_PUSH socket, My broker listens on tcp://localhost:port1 and resends the message to tcp://localhost:port2 and my consumer listens on tcp://localhost:port2 using ZMQ_PULL socket. I am using a broker instead of peer to to peer communication in ZeroMQ to to make the performance comparison fair to other message queue implementation that uses brokers.
  3. Qpid C++ message broker: I used a "fanout" type exchange and a queue with default configuration. I used the Qpid C++ client library.

Following is the performance result:

  1. RabbitMQ: it takes about 1 second to receive 10,000 messages.
  2. ZeroMQ: It takes about 15 milli seconds to receive 10,000 messages.
  3. Qpid: It takes about 4 seconds to receive 10,000 messages.

Questions:

  1. Have anyone run similar performance comparison between the message queues? Then I like to compare my results with yours.
  2. Is there any way I could tune RabbitMQ or Qpid to make it performance better?

Note:

The tests were done on a virtual machine with two allocated processor. The result may vary for different hardware, however I am mainly interested in relative performance of the MQ products.


Source: (StackOverflow)

RabbitMQ / AMQP: single queue, multiple consumers for same message?

I am just starting to use RabbitMQ and AMQP in general.

  • I have a queue of messages
  • I have multiple consumers, which I would like to do different things with the same message.

Most of the RabbitMQ documentation seems to be focused on round-robin, ie where a single message is consumed by a single consumer, with the load being spread between each consumer. This is indeed the behavior I witness.

An example: the producer has a single queue, and send messages every 2 sec:

var amqp = require('amqp');
var connection = amqp.createConnection({ host: "localhost", port: 5672 });
var count = 1;

connection.on('ready', function () {
  var sendMessage = function(connection, queue_name, payload) {
    var encoded_payload = JSON.stringify(payload);  
    connection.publish(queue_name, encoded_payload);
  }

  setInterval( function() {    
    var test_message = 'TEST '+count
    sendMessage(connection, "my_queue_name", test_message)  
    count += 1;
  }, 2000) 


})

And here's a consumer:

var amqp = require('amqp');
var connection = amqp.createConnection({ host: "localhost", port: 5672 });
connection.on('ready', function () {
  connection.queue("my_queue_name", function(queue){
    queue.bind('#'); 
    queue.subscribe(function (message) {
      var encoded_payload = unescape(message.data)
      var payload = JSON.parse(encoded_payload)
      console.log('Recieved a message:')
      console.log(payload)
    })
  })
})

If I start the consumer twice, I can see that each consumer is consuming alternate messages in round-robin behavior. Eg, I'll see messages 1, 3, 5 in one terminal, 2, 4, 6 in the other.

My question is:

  • Can I have each consumer receive the same messages? Ie, both consumers get message 1, 2, 3, 4, 5, 6? What is this called in AMQP/RabbitMQ speak? How is it normally configured?

  • Is this commonly done? Should I just have the exchange route the message into two separate queues, with a single consumer, instead?


Source: (StackOverflow)

How to Guarantee Message delivery with Celery?

I have a python application where I want to start doing more work in the background so that it will scale better as it gets busier. In the past I have used Celery for doing normal background tasks, and this has worked well.

The only difference between this application and the others I have done in the past is that I need to guarantee that these messages are processed, they can't be lost.

For this application I'm not too concerned about speed for my message queue, I need reliability and durability first and formost. To be safe I want to have two queue servers, both in different data centers in case something goes wrong, one a backup of the other.

Looking at Celery it looks like it supports a bunch of different backends, some with more features then the others. The two most popular look like redis and RabbitMQ so I took some time to examine them further.

RabbitMQ: Supports durable queues and clustering, but the problem with the way they have clustering today is that if you lose a node in the cluster, all messages in that node are unavailable until you bring that node back online. It doesn't replicated the messages between the different nodes in the cluster, it just replicates the metadata about the message, and then it goes back to the originating node to get the message, if the node isn't running, you are S.O.L. Not ideal.

The way they recommend to get around this is to setup a second server and replicate the file system using DRBD, and then running something like pacemaker to switch the clients to the backup server when it needs too. This seems pretty complicated, not sure if there is a better way. Anyone know of a better way?

Redis: Supports a read slave and this would allow me to have a backup in case of emergencies but it doesn't support master-master setup, and I'm not sure if it handles active failover between master and slave. It doesn't have the same features as RabbitMQ, but looks much easier to setup and maintain.

Questions:

  1. What is the best way to setup celery so that it will guarantee message processing.

  2. Has anyone done this before? If so, would be mind sharing what you did?


Source: (StackOverflow)

RabbitMQ AMQP.BasicProperties.Builder values

In the RabbitMQ/AMQP Java client, you can create an AMQP.BasicProperties.Builder, and use it to build() an instance of AMQP.BasicProperties. This built properties instance can then be used for all sorts of important things. There are lots of "builder"-style methods available on this builder class:

BasicProperties.Builder propsBuilder = new BasicProperties.Builder();
propsBuilder
    .appId(???)
    .clusterId(???)
    .contentEncoding(???)
    .contentType(???)
    .correlationId(???)
    .deliveryMode(2)
    .expiration(???)
    .headers(???)
    .messageId(???)
    .priority(???)
    .replyTo(???)
    .timestamp(???)
    .type(???)
    .userId(???);

I'm looking for what fields these builer methods help "build-up", and most importantly, what valid values exist for each field. For instance, what is a clusterId, and what are its valid values? What is type, and what are its valid values? Etc.

I have spent all morning scouring:

In all these docs, I cannot find clear definitions (besides some vague explanation of what priority, contentEncoding and deliveryMode are) of what each of these fields are, and what their valid values are. Does anybody know? More importantly, does anybody know where these are even documented? Thanks in advance!


Source: (StackOverflow)

How to create a delayed queue in RabbitMQ?

What is the easiest way to create a delay (or parking) queue with Python, Pika and RabbitMQ? I have seen an similar questions, but none for Python.

I find this an useful idea when designing applications, as it allows us to throttle messages that needs to be re-queued again.

There are always the possibility that you will receive more messages than you can handle, maybe the HTTP server is slow, or the database is under too much stress.

I also found it very useful when something went wrong in scenarios where there is a zero tolerance to losing messages, and while re-queuing messages that could not be handled may solve that. It can also cause problems where the message will be queued over and over again. Potentially causing performance issues, and log spam.


Source: (StackOverflow)

Rabbitmq or Gearman - choosing a jobs queue [closed]

At work, we need to build a jobs server for things like sending emails, building PDFs, crunching some data, etc. Obviously, we'd like to build on some sort of generic queueing system. I'm familiar with Gearman, and that this is exact problem that it tries to solve: putting jobs on a queue where workers come to pick them up. However, I'm seeing lots of mentions of Rabbitmq and am unclear how it's used in this scenario.

Is Rabbitmq a good framework to build a distributed jobs system on top of?


Source: (StackOverflow)

Verify version of rabbitmq

How can I verify which version of rabbitmq is running on a server?

Is there a command to verify this?


Source: (StackOverflow)

Deleting all pending tasks in celery / rabbitmq

How can I delete all pending tasks without knowing the task_id for each task?


Source: (StackOverflow)