Consumer receive message only once

19 views
Skip to first unread message

lqj19...@gmail.com

unread,
Nov 30, 2016, 11:54:40 PM11/30/16
to simpleamqpclient-users
The consumer receive message only once. The code is as follows:

Channel::ptr_t channel = Channel::Create();
 string QUEUE_NAME = "hello";
 cout << " [*] Waiting for messages. To exit press CTRL+C" << endl;
 string consumer = channel->BasicConsume(QUEUE_NAME, "", true, false);
 while (1){
  BasicMessage::ptr_t msg_out = channel->BasicConsumeMessage(consumer)->Message();
  cout << "Message text: " << msg_out->Body() << endl;
 }

I 'm sure the publisher is fine. Because when I use consumer written by python, it can receive every message send by the publisher. But when I use consumer in C++, it does not work. The consumer just receive the first messages. Why it happens? Can anyone help me? Thank you very much!

Alan Antonuk

unread,
Dec 1, 2016, 1:45:48 AM12/1/16
to lqj19...@gmail.com, simpleamqpclient-users
You need to explicitly ack the received message using Channel::BasicAck or set no_ack when declaring the consumer (e.g., no_ack = true when calling Channel::BasicConsume.

-Alan

--
You received this message because you are subscribed to the Google Groups "simpleamqpclient-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simpleamqpclient-...@googlegroups.com.
To post to this group, send email to simpleamqpc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/simpleamqpclient-users/14a8d33f-0183-42a4-88c4-30730affa9c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages