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

feat: use scoped message handlers via pumps/routers #397

Merged

Conversation

stijnmoreels
Copy link
Member

Enhances the current message handler registration by scoping any message handler registrations to a pump or router. This means that message handlers registered for another pump/router cannot be used during message routing.

This is a follow-up on the background jobs issue: arcus-azure/arcus.backgroundjobs#200

The cool 😎 thing about this enhancement, is that it does not changes anything for single-message pump/router registrations; but changes the way we work with multiple pumps (which is the case when background jobs are involved).

Closes #395

@netlify
Copy link

netlify bot commented Jun 2, 2023

Deploy Preview for arcus-messaging canceled.

Name Link
🔨 Latest commit 3a0881b
🔍 Latest deploy log https://app.netlify.com/sites/arcus-messaging/deploys/64b8e1cf5d5fb6000887c24c

@stijnmoreels
Copy link
Member Author

/azp run CI - Arcus.Messaging

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@stijnmoreels stijnmoreels changed the title feat: use scoped message handlers via pumps/routers (🚧) feat: use scoped message handlers via pumps/routers Jul 18, 2023
@stijnmoreels stijnmoreels marked this pull request as ready for review July 18, 2023 06:24
@fgheysels
Copy link
Member

This means that message handlers registered for another pump/router cannot be used during message routing.

What do you mean exactly ?

@stijnmoreels
Copy link
Member Author

This means that message handlers registered for another pump/router cannot be used during message routing.

What do you mean exactly ?

In situations where you have two different message pumps/routers, the message handlers were previously shared among them. This PR makes sure that each set of message handlers is scoped to the pump/router; meaning that a message handler with the same message type will not 'wrongly' process a message that was meant for another pump/router.
This is especially the case with background jobs, where you process 'events'; and pumps have the same event/message type to process.

@fgheysels
Copy link
Member

This means that message handlers registered for another pump/router cannot be used during message routing.

What do you mean exactly ?

In situations where you have two different message pumps/routers, the message handlers were previously shared among them. This PR makes sure that each set of message handlers is scoped to the pump/router; meaning that a message handler with the same message type will not 'wrongly' process a message that was meant for another pump/router. This is especially the case with background jobs, where you process 'events'; and pumps have the same event/message type to process.

Ok thanks. But I would assume that this is something that could not ever happen, as the message handler is registered with a message-pump anyway ?

@stijnmoreels
Copy link
Member Author

stijnmoreels commented Jul 20, 2023

Ok thanks. But I would assume that this is something that could not ever happen, as the message handler is registered with a message-pump anyway ?

It seems that we do due to the code syntax, but behind the scenes they are all registered in the same dependency container.
I succeeded in reproducing it by registering our two background jobs (auto-update secret in cache, auto-restart message pump), as they are both registered on 'secret new version created' events on Key Vault.
This PR makes sure that your assumption that the code syntax proposes is reality behind the scenes.

@stijnmoreels stijnmoreels merged commit 0e2ac22 into arcus-azure:main Jul 20, 2023
16 checks passed
@stijnmoreels stijnmoreels deleted the feature/scoped-message-handlers branch July 20, 2023 07:57
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

Successfully merging this pull request may close these issues.

Limit scope of message handlers by only running registered handlers linked to message pump
2 participants