Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After the first messages read no more messages are received #1

Closed
a14n opened this issue Jul 24, 2015 · 2 comments
Closed

After the first messages read no more messages are received #1

a14n opened this issue Jul 24, 2015 · 2 comments

Comments

@a14n
Copy link
Contributor

a14n commented Jul 24, 2015

I just did a quick test with this package (version 0.0.1) and the following code. After the first message (or bunch of messages) no more messages are received and the rabbitmq queue grows up.

import "package:dart_amqp/dart_amqp.dart";

main() async {
  // auto-connect to localhost:5672 using guest credentials
  Client client = new Client();
  final channel = await client.channel();
  final queue = await channel.queue("test", durable: true);
  final consumer = await queue.consume();
  consumer.listen((message) {
    // Get the payload as a string
    print(" [x] Received string: ${message.payloadAsString}");

    // Or unserialize to json
    print(" [x] Received json: ${message.payloadAsJson}");

    // Or just get the raw data as a Uint8List
    print(" [x] Received raw: ${message.payload}");

    message.ack();
  });
}
@achilleasa
Copy link
Owner

The problem seems to be caused by the message.ack() statement. The default parameters for queue.consume specify the noAck: true flag. Rabbitmq is not expecting an ACK for messages so it sends back an error (you can receive that by adding the onError handler to consumer.listen)

To resolve the problem either remove message.ack() or change the final consumer = await queue.consume(); to final consumer = await queue.consume(noAck: false); if you need to ack messages.

@a14n
Copy link
Contributor Author

a14n commented Aug 7, 2015

Thanks! My mistake.

BTW thanks for this package :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants