Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

[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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant