Antti / rust-amqp

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

channel rpc and async messages #18

Closed davidszotten closed 9 years ago

davidszotten commented 9 years ago

trying to run what is mostly the consumer.rs example. however, if i bind to a queue which already has messages, i get an error Err(Protocol("Unexpected method frame: basic.deliver, expected: basic.consume-ok"))

i think the issue is the second basic_consume, which expects the very next message from the server to be the consume-ok, but since we've already started consuming, the server is already sending us messages

Antti commented 9 years ago

@davidszotten you are right. We need to handle synchronous and asynchronous methods differently. Synchronous methods are marked in amqp-rabbitmq-0.9.1.json, all other must be asynchronous.

Probably we should pass over asynchronous methods in the rpc calls, so they would be handled elsewhere (in the consumers).

Antti commented 9 years ago

There's bunch of methods which require special async handling, most of them are from basic class:

Async: basic:ack
Async: basic:deliver
Async: basic:get-empty
Async: basic:nack
Async: basic:publish
Async: basic:recover-async
Async: basic:reject
Async: basic:return
Async: connection:blocked
Async: connection:unblocked
Antti commented 9 years ago

The current workaround (until we fix this) would be to declare consumers on a different channels.

Antti commented 9 years ago

@davidszotten I've commited a patch, which should fix this problem, can you test please?

davidszotten commented 9 years ago

hey, thanks! will give it a whirl. (may take a little while, this is only for a side-project)

davidszotten commented 9 years ago

works great, thanks!