achilleasa / dart_amqp

Dart AMQP client implementing protocol version 0.9.1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unknown disconnection from a queue

MattiaPispisa opened this issue · comments

Hi,

I'm using dart_ampq to listen a queue like in your example. I am testing the application on an android emulator.
After a while, the application no longer listens to the queue and does so without invoking any error or without executing any print (see code below)

ConnectionSettings settings = new ConnectionSettings (
        port: port,
        host: host,
        authProvider: new PlainAuthenticator (userName, password))

 _client = Client(settings: settings);

try {
      _client
          .channel ()
          .then ((Channel channel) => channel.queue (queueName, durable: true))
          .then ((Queue queue) => queue.consume ())
          .then (
            (Consumer consumer) => consumer.listen ((AmqpMessage message) {
              // do stuff
            }, onDone: () {
              print ("onDone");
            }, onError: (e, k) {
              print ("onError");
            }),
          )
          .whenComplete (() {
        print ("whenComplete");
      }). then ((t) {
        print ("then");
      });
    } on ConnectionException catch (e) {
      print ("ConnectionException $e");
    }

Am I doing something wrong ?

The create-queue, consume, listen part looks correct. Not sure what could cause this behavior unless you have another consumer running in the background that consumes messages off the queue and thus starves this consumer.

I wonder if you would get the same issue if you used an exchange.