Skip to content

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

@jordantw9

Description

@jordantw9

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions