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

[BUG] for v4.9.0 to RegisterSubscriber with Queue #2687

Open
jordantw9 opened this issue Jan 5, 2024 · 0 comments
Open

[BUG] for v4.9.0 to RegisterSubscriber with Queue #2687

jordantw9 opened this issue Jan 5, 2024 · 0 comments

Comments

@jordantw9
Copy link

Describe the bug

I used micro.go's RegisterSubscriber to register an event and passed server.SubscriberQueue as an opt. Unfortunately, I encountered an issue where, during rpcServer's Register (server\rpc_server.go:697), triggering s.HandleEvent for each s.subscribers occurs. However, within HandleEvent, ProcessMessage (server\rpc_router.go:511) triggers each subscription of router.subscribers again. This causes my subscriptions to receive duplicate messages.

For instance, I registered the same topic and used different Queues to differentiate, with corresponding handlers, h_a, h_b, h_c:

RegisterSubscriber("EVENT_1", s, h_a, append(opts, server.SubscriberQueue("A"))...)
RegisterSubscriber("EVENT_1", s, h_b, append(opts, server.SubscriberQueue("B"))...)
RegisterSubscriber("EVENT_1", s, h_c, append(opts, server.SubscriberQueue("C"))...)

Then, when I publish this topic:

micro.NewEvent(T"EVENT_1", DefaultService.Client()).Publish(ctx, msg, opts...)

My handler, h_a, is triggered three times because each registration calls s.HandleEvent with s.subscribers, but the message is traversing router.subscribers again during ProcessMessage.

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

1 participant