Skip to content

Sending a message from a handler #16

Open
@mludvig

Description

@mludvig

I'm trying to use MessageBus in multi-threaded program where one thread (e.g. Button) sends a ButtonMessage() to the bus. Then I've got a Controller thread that's subscribed to the ButtonMessage() messages and receives it. In the Controller.handler() it decides what to do with it and then sends another message, e.g. DisplayMessage() with some payload back to the messagebus which should be handled by the Display thread. At that point all the hell breaks loose, the Controller.handler() starts to get called recursively, the DisplayMessage() is never delivered and in the end it all crashes.

As a workaround I have to listen for the ButtonMessage() in Display which feels like an anti-pattern, the Display shouldn't care where the event comes from or the Button shouldn't need to know what kind of DisplayMessage() to send. It should all be glued together only in the Controller.

It'd be great if:

  • we could send messages in a fire and forget mode - most of the time my senders don't care about the return values, especially not from other threads.
  • we could send new messages from message handlers - my Controller would then be the only thing that needs to know about all the other components and the messages they expect but the individual components won't have to have a clue.

Are there any plans to do that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions