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

消费者 consume 支持异步 #44

Closed
xujiesh0510 opened this issue Mar 29, 2022 · 2 comments
Closed

消费者 consume 支持异步 #44

xujiesh0510 opened this issue Mar 29, 2022 · 2 comments

Comments

@xujiesh0510
Copy link

xujiesh0510 commented Mar 29, 2022

看了下源码,消费者是 pull 模型。 拉取消息都做了 await,Consume 就改下异步嘛? 能不能安排上?

var pr = await Pull(mq, offset, BatchSize, SuspendTimeout);
                    if (pr != null)
                    {
                        switch (pr.Status)
                        {
                            case PullStatus.Found:
                                if (pr.Messages != null && pr.Messages.Length > 0)
                                {
                                    // 触发消费
                                    **var rs = Consume(mq, pr);**  这边能改成异步么? await ConsumeAsync

                                    // 更新偏移
                                    if (rs)
                                    {
                                        st.Offset = pr.NextBeginOffset;
                                        // 提交消费进度
                                        await UpdateOffset(mq, st.Offset);
                                    }
                                }
@nnhy
Copy link
Member

nnhy commented Mar 29, 2022

564ae4f

@xujiesh0510
Copy link
Author

感谢大佬

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