Menu

Breaking things with RabbitMQ 3.0

RabbitMQ includes a bunch of cool new features. But in order to implement some of them we needed to change some things. So in this blog post I'm going to list some of those things in case you need to do anything about them.

Mirror queue policies

What changed? In RabbitMQ 3.0, queue mirroring is no longer controlled by the x-ha-policy argument when declaring a queue. Your applications can continue to declare this argument, but it won't cause queues to be mirrored. Instead you can declare one or more policies which control which queues are mirrored, and how.

Why did it change? As anyone who's used mirrored queues will tell you, requiring applications to know which queues are mirrored is a pain. The new approach puts configuration in the broker, where it belongs, and also supports changing mirroring policy at any time.

What should I do? You need to make sure your queues are still mirrored. For the full documentation see here, but if you just want to make sure that all queues (except those with auto-generated names) are mirrored across all nodes, run:

rabbitmqctl set_policy HA '^(?!amq\.).*' '{"ha-mode": "all"}'

New federation

What changed? Federation is configured quite differently in RabbitMQ 3.0. The x-federation exchange type no longer exists; instead normal exchanges are made federated by policy in the same way that HA queues are. Furthermore, upstreams are defined dynamically as well.

Why did it change? Again, your applications should not need to know about federation. Federation configuration in rabbitmq.config was complicated and confused many people. And needing to restart the broker to add a new upstream was not fun.

But I have a working federation setup! You broke it. Migrating to the new way of doing federation will take a bit of work. In the mean time you can use the rabbitmq_old_federation plugin. This is a backport of the 2.8.7 federation plugin for RabbitMQ 3.0. To use it:

rabbitmq-plugins disable rabbitmq_federation

rabbitmq-plugins enable rabbitmq_old_federation

and then edit your rabbitmq.config file so that the rabbitmq_federation section is renamed to rabbitmq_old_federation.

New clustering

What changed? The clustering-setup commands in rabbitmqctl have changed.

Why did it change? The old ones were not very user friendly.

What do I need to do? If you have an existing cluster, nothing. If you write scripts to create clusters, you will need to edit them. In particular, rabbitmqctl cluster should be replaced with rabbitmqctl join_cluster, but:

  • You don't need to invoke rabbitmqctl reset first
  • You don't need to list all the nodes on the command line; if you give more than one node then they will be taken as a list of nodes to try to cluster with
  • Whether the new node is a disc or RAM node is determined by the --disc and --ram flags. The default is to be a disc node.

For more details, see the documentation.

Removal of "immediate" flag

What changed? We removed support for the rarely-used "immediate" flag on AMQP's basic.publish.

Why on earth did you do that? Support for "immediate" made many parts of the codebase more complex, particularly around mirrored queues. It also stood in the way of our being able to deliver substantial performance improvements in mirrored queues.

What do I need to do? If you just want to be able to publish messages that will be dropped if they are not consumed immediately, you can publish to a queue with a TTL of 0.

If you also need your publisher to be able to determine that this has happened, you can also use the DLX feature to route such messages to another queue, from which the publisher can consume them.

frame_max

What changed? The RabbitMQ server now disconnects clients which send frames larger than the negotiated frame_max setting for the connection.

Why did it change? Malicious (or badly written) clients could send arbitrarily large frames and cause the server to run out of memory.

Why do I care? Unfortunately some clients don't implement AMQP framing correctly. RabbitMQ 3.0 will allow clients to exceed frame_max by a fudge factor of a few bytes (to allow for off by one errors and incorrectly excluding the frame header) but if your client has broken framing you will be disconnected after trying to send a message larger than frame_max (which by default comes out to 128kb; see the documentation on how to raise this).

Management and JSON-RPC channel port changes

What changed? The management plugin now listens on port 15672, not 55672. JSON-RPC channel now listens on 15670, not 55670.

Why did it change? The old ports were in the ephemeral port range on many operating systems, meaning that web browsers and other client applications might use these ports arbitrarily. You're not supposed to listen on these ports.

In particular we noticed that the management plugin web UI could, when pointed at a stopped broker on localhost, end up getting the browser to connect to itself on port 55672. This prevented the broker from starting again.

What do I have to do? Hopefully nothing. RabbitMQ will attempt to open the old port and send HTTP redirects to the new one. But if you're using an application other than a web browser to talk to the HTTP API, it might not support HTTP redirects. If it doesn't, you'll need to point it at the new port.

Note that rabbitmqadmin prior to version 3.0 was such an application. Oops.

Also note that the STOMP plugin still listens on port 61313. Although this is in the ephemeral range, it's the closest thing STOMP has to a standard port, so we have to stick with it.

expiration property

What changed? We now expect the expiration field in message properties to be parseable as an integer if it's set at all.

Why did it change? In order to support per-message TTL we need a place to get the TTL of the message from, and this is the obvious place. Unfortunately the AMQP standard defines it as a string, so we try to parse it as an integer and will throw a channel exception if it is not.

What do I have to do? Make sure that if you're using that property then you're using it because you expect RabbitMQ to expire the message, and make sure it's set to a string which can be parsed as an integer.

11 Responses to “Breaking things with RabbitMQ 3.0”

  1. Wiebe Says:

    Thanks!

    There seems to be a small difference in the way in messages with an expiration date are passed:
    https://groups.google.com/forum/?fromgroups=#!topic/masstransit-discuss/IxiQzXxbtN0

  2. Simon MacMullen Says:

    Thank you Wiebe!

    Huh. So what's happening is that in RabbitMQ 3.0 we parse and handle the "expiration" property of each message for per-message TTL. (see http://www.rabbitmq.com/ttl.html#per-message-ttl). Which means we expect it to be an integer. But it looks like MassTransit is using that for something else.

    I will reply in the Google group.

  3. Wiebe Says:

    Hi Simon,

    Thanks for the quick response!

  4. Pavel Says:

    RE: In particular, rabbitmqctl cluster should be replaced with rabbitmqctl join_cluster

    Is there any way to get pre-3.0 documentation? Links from download archive (e.g. http://www.rabbitmq.com/releases/rabbitmq-server/v2.8.4/man/rabbitmqctl.1.man.xml) redirect to the current one (http://www.rabbitmq.com/man/rabbitmqctl.1.man.html) which is simply confusing as commands like "join_cluster" are not supported.

    P.S. Is changeclusternode_type also a new command? It doesn't work for me either.

  5. Simon MacMullen Says:

    Hi Pavel. Man pages are included in each release, so for that specific case you can check your locally installed version.

    We will do something about the web docs soon, several people have been asking.

  6. Piyush Says:

    Hi, Using .NET client for RabbitMQ, the request is not getting published if the 'Immediate' flag is set to true. In this case 'BasicPublish' does not throw any exception or provide any message.

  7. Simon MacMullen Says:

    Hi Piyush - since publishing is asynchronous, your app may not see an exception thrown on your channel until you attempt to publish more messages or execute a synchronous method. Could that be what you're seeing?

  8. DaHong.He Says:

    Hi, Using .NET client for RabbitMQ, client version is 2.7.1 ,rabbitmq server is 3.1.1, "Piyush" and I met the same problem,
    Multiple Call 'BasicPublish' method send message, throw Error:
    System.ObjectDisposedException System.Net.Sockets.Socket
    {"无法访问已释放的对象。rn对象名:“System.Net.Sockets.Socket”。"}

    But,Very slow calls "sendMsg()" no problem!

    But,rabbitmq server RabbitMQ 2.8.7 no problem!

    my c# code like:

    public void sendMsg()
    {
    try
    {
    string url = txtUrl.Text;
    ConnectionFactory cf = new ConnectionFactory();
    cf.Uri = url;
    cf.RequestedHeartbeat = 0;
    using (IConnection conn = cf.CreateConnection())
    {
    using (IModel ch = conn.CreateModel())
    {
    ch.ExchangeDeclare(txtExchange.Text, ExchangeType.Direct,true);
    ch.QueueDeclare(txtQueue.Text, true, false, false, null);
    ch.QueueBind(txtQueue.Text, txtExchange.Text, txtQueue.Text, null);

                        IMapMessageBuilder b = new MapMessageBuilder(ch);                       
    
                        INDEX++;
                        string headContent=this.txtHead.Text;
                        string bodyContent = this.txtBody.Text;                        
                        b.Headers["header"] = headContent;
    
                            ch.BasicPublish(txtExchange.Text,txtRouteKey.Text, false, false, (IBasicProperties)b.GetContentHeader(), Encoding.UTF8.GetBytes(bodyContent));
    
                    }
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
            btnSend.Enabled = true;
        }
    
  9. DaHong.He Says:

    I'm sorry, I am Chinese, English is not good ^_^

  10. DaHong.He Says:

    Problem solved, use 3.1.1 the client is Ok

  11. Shuvam Das Says:

    Hi all,

    I want to bind exchange and queue from rabbitmq client. I did not get any piece of code that is binding exchange and queue.
    I tried with amqpexchangebind() api, but it did not work.
    If you have any solution please let me know.

    Thanks in advance.

    Regards,
    Shuvam Das.