Antti / rust-amqp

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

Binding queue to exchange error #60

Closed lorenzotomasini closed 6 years ago

lorenzotomasini commented 6 years ago

Hi All,

i am trying to use the exchange_bind method, but i am having some troubles. I am a rust beginner so i am probably doing something wrong.

the code i run:

...
    debug!("Declaring exchange...");
    let exchange_declare1 = channel.exchange_declare(exchange_name, "topic",true, true, false, false, false, Table::new());
    debug!("Exchange declare: {:?}", exchange_declare1);
    debug!("Binding {} with {}", queue_name, exchange_name);
    match channel.exchange_bind(queue_name, exchange_name, queue_name, Table::new()) {
        Err(err) => {
            error!("Error binding: {:?}", err);
            std::process::exit(32);
        },
        Ok(_) => {},
    };
    debug!("Bind to exchange");
    channel.basic_prefetch(1).ok().expect("Failed to prefetch");
...

the exchange already exists and the error i get is:

2017-12-01 19:33:35 [ob] DEBUG ob: Declaring exchange...
2017-12-01 19:33:35 [ob] DEBUG ob: Exchange declare: Ok(DeclareOk)
2017-12-01 19:33:35 [ob] DEBUG ob: Binding rust with exchange
2017-12-01 19:33:35 [ob] ERROR ob: Error binding: Protocol("Unexpected method frame: channel.close, expected: exchange.bind-ok")

Everything works great (i am already basic_consume and basic_produce before that snippet without problems), but the exchange bind. I don't understand what i am doing wrong. Can you point me to the right direction?

thanks

lorenzotomasini commented 6 years ago

Hi all,

i finally found the time to debug a little more, i did not think enough on what i was doing. I was using the wrong method for my purposes: i changed exchange_bind --> queue_bind and works like a charm.

Thank you guys for that library and sorry for my mistake!