achilleasa / dart_amqp

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

Unknown disconnection from a queue #45

Closed MattiaPispisa closed 3 years ago

MattiaPispisa commented 3 years ago

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 ?

achilleasa commented 3 years ago

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.