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

Msg lost when consumer is set to no ack #741

Open
12doge-LEO opened this issue Nov 4, 2022 · 6 comments
Open

Msg lost when consumer is set to no ack #741

12doge-LEO opened this issue Nov 4, 2022 · 6 comments

Comments

@12doge-LEO
Copy link

Hello,

Recently I found my rabbitmq client lost msgs when the network issue occured. The rabbitmq server log shows the msg was published and received at the same monent. Like:

2022-11-03 14:28:30:458: Message published
2022-11-03 14:28:30:458: Message received

After investigation, I found the consumer is inited with no_ack = true.

amqp_basic_consume(conn, 1, queuename, amqp_empty_bytes, 0, 1, 0, amqp_empty_table);

Can you please help me check if this no_ack config leads to the msg lost issue?

@lesio999
Copy link

I think, I had the same issue,, where like more than 1 msg was pushed to the consumer and in case of issue at client multiple msgs were lost. That pushed me to implement amqp_basic_get(). But I'm looking at amqp_basic_consume again due to higher CPU utilization by basic_get in very tight loop.
I would really like to hear about proper usage of amqp_basic_consume.
is it possible to have only 1 message at the time and still use amqp_basic_consume?

@reunanen
Copy link

reunanen commented Dec 2, 2023

is it possible to have only 1 message at the time and still use amqp_basic_consume?

Have you tried setting prefetch_count to 1?

Maybe something along these lines?

amqp_basic_qos_t req;
req.prefetch_size = 0;
req.prefetch_count = 1;
req.global = false;

amqp_method_number_t method = AMQP_BASIC_QOS_METHOD;
amqp_method_number_t method_ok = AMQP_BASIC_QOS_OK_METHOD;

amqp_rpc_reply_t result = amqp_simple_rpc(conn, 1, method, &method_ok, &req);

@lesio999
Copy link

lesio999 commented Dec 5, 2023

I came across that setting using c# client in some other part of our system. will be trying it in c++ shortly.

thanks for response.

@lesio999
Copy link

lesio999 commented Feb 15, 2024 via email

@reunanen
Copy link

Yeah, I would expect that too.

You may also try basic.get, instead of basic.consume. For more information, see e.g. this (just the first Google hit): https://www.cloudamqp.com/blog/rabbitmq-basic-consume-vs-rabbitmq-basic-get.html

Yes I know that using basic.get is generally discouraged.

@lesio999
Copy link

lesio999 commented Feb 16, 2024 via email

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

3 participants