-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
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.