Antti / rust-amqp

AMQP client in pure rust. Corresponds to rabbitmq spec.
MIT License
247 stars 45 forks source link

Channel.exchange_declare: Unexpected method frame #36

Open kopiczko opened 8 years ago

kopiczko commented 8 years ago

Steps to reproduce: Notice auto_delete changes.

    channel.exchange_declare(exchange,
                          "fanout",
                          false, // pssive
                          false, // durable
                          false, // auto_delete
                          false, // internal
                          false, // nowait
                          Table::new())
        .unwrap();
    channel.exchange_declare(exchange,
                          "fanout",
                          false, // pssive
                          false, // durable
                          true, // auto_delete
                          false, // internal
                          false, // nowait
                          Table::new())
        .unwrap();

Panics with: AMQP Error: Unexpected method frame: channel.close, expected: exchange.declare-ok.

I'd expect exchange_declare to tell me that exchange is already declared without _autodelete feature.

Antti commented 8 years ago

The current implementation is not handling channel errors well. The only expected response from these kind of calls is a corresponding OK method, like exchange.declare-ok, I guess it should also expect channel.close, and return it as an error.

Although, for this particular error it is strange that the server returns an error, because in the protocol specification it says that the server MUST ignore the auto-delete field if the exchange already exists.