amqp assertQueue bork a connection meaning

Viewed 1124

In amqp's assertQueue API Documentation, it states:

Assert a queue into existence. This operation is idempotent given identical arguments; however, it will bork the channel if the queue already exists but has different properties (values supplied in the arguments field may or may not count for borking purposes; check the borker's, I mean broker's, documentation).

http://www.squaremobius.net/amqp.node/channel_api.html#channel_assertQueue

I am asking what it means by bork(ing) the channel. I tried google but can't find anything relevant.

2 Answers

Bork: English meaning is to obstruct something.

As per the documentation in the question, it says

however, it will bork the channel if the queue already exists but has different properties

this means if you try to create a channel which has the same properties of a channel which already exits, nothing would happen cause it is idempotent (meaning repeating the same action with no different result, e.g. a REST API GET request which fetches data for id say 123, will return the same data every time unless updated, a pretty funny video explaining the impotent concept), but if you try to create a channel with the same name but different properties, the channel creation shall be "borked" i.e. obstructed.

In the code below, we create the channel again,

 var ok0 = ch.assertQueue(q, {durable: false});// creating the first time
 var ok1 = ch.assertQueue(q, {durable: true});// creating the second time again with different durable property value

it throws an error

"PRECONDITION_FAILED - inequivalent arg 'durable' for queue 'hello' in vhost '/': received 'true' but current is 'false'"

This means the you are trying to make the same channel with different properties, i.e. the durable property is different to the existing channel and hence it has been borked.

[2]: Answer by @Like Bakken

The RabbitMQ team monitors this mailing list and only sometimes answers questions on StackOverflow.

Having said that, did you try calling assertQueue twice, with different properties the second time? You would have answered your own question very quickly.

I used this code to create this test program:

#!/usr/bin/env node

var amqp = require('amqplib');

amqp.connect('amqp://localhost').then(function(conn) {
  return conn.createChannel().then(function(ch) {
    var q = 'hello';
    var ok0 = ch.assertQueue(q, {durable: false});
    return ok0.then(function(_qok) {
        var ok1 = ch.assertQueue(q, {durable: true});
        return ok1.then(function(got) {
            console.log(" [x] got '%s'", got);
            return ch.close();
        });
    });
  }).finally(function() { conn.close(); });
}).catch(console.warn);

Then, start RabbitMQ and run your test code. You should see output like this:

$ node examples/tutorials/assert-borked.js
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: Channel closed by server: 406 (PRECONDITION-FAILED) with message "PRECONDITION_FAILED - inequivalent arg 'durable' for queue 'hello' in vhost '/': received 'true' but current is 'false'"
    at Channel.C.accept
Related