achilleasa / dart_amqp

Dart AMQP client implementing protocol version 0.9.1
MIT License
79 stars 40 forks source link

Channel Exceptions, Channel Closes, etc don't inform Consumers #99

Closed rajmaniar closed 1 year ago

rajmaniar commented 1 year ago

When a channel exception is thrown or channel is closed the Consumer's error or done callbacks are not invoked.

Consider:

var c = Client();
var chan = await c.channel();
var queue = await chan.queue("test123", autoDelete: true);
var consumer = await queue.consume(noAck: true);
consumer.listen((event) {print("queue: $event");}, onDone: (){print("consumer done");}, onError: (e){print("consumer error: $e");}, cancelOnError: true);

try {
    await chan.queue("test456", passive: true);
 } on QueueNotFoundException {
    print("QueueNotFoundException will break the channel");
}
await Future.delayed(Duration(seconds: 60));

In the above scenario the consumer done or consumer error are never emitted and the stream isn't closed.

It seems to me the channel exception handler should loop over all the consumer stream controllers, pass the error down and/or close the streams.

achilleasa commented 1 year ago

Thanks for reporting this! A fix is on the way.