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

Messages without routing are now handled immediately instead of throwing exception #4

Merged
merged 4 commits into from
Sep 4, 2023

Conversation

JanMikes
Copy link
Contributor

@JanMikes JanMikes commented Aug 6, 2023

This PR brings behaviour that is documented in the official symfony/messenger docs:

Screenshot 2023-08-06 at 18 33 41

@JanMikes
Copy link
Contributor Author

JanMikes commented Aug 6, 2023

In the end i found out by step debugging, that it was probably a typo - default value was a true, but default bus has it set to false :-). So it was really just oneline change + added test for it.

@JanMikes JanMikes marked this pull request as ready for review August 6, 2023 17:43
@JanMikes JanMikes changed the title Draft: Messages without routing are now handled immediately instead of throwing exception Messages without routing are now handled immediately instead of throwing exception Aug 6, 2023
@f3l1x
Copy link
Member

f3l1x commented Aug 7, 2023

Which transport is used without routing? Can you point somewhere in messenger code?

@JanMikes
Copy link
Contributor Author

JanMikes commented Aug 7, 2023

I was a little bit surprised during debugging, it does not send to any transport at all - https://github.com/symfony/messenger/blob/7.0/Middleware/SendMessageMiddleware.php#L65

Sending to transport is skipped and the message is handled directly by the handler in next middleware: https://github.com/symfony/messenger/blob/7.0/Middleware/HandleMessageMiddleware.php#L74

this is default behaviour and was mistakenly overwritten with the default bus created by nette extension - https://github.com/contributte/messenger/blob/master/src/DI/MessengerExtension.php#L94

even few lines above the default is true https://github.com/contributte/messenger/blob/master/src/DI/MessengerExtension.php#L82 😄

@JanMikes
Copy link
Contributor Author

JanMikes commented Aug 7, 2023

When routing to sync transport is used, it only emulates sending - the message is re-dispatched with stamp so the send middleware is skipped: https://github.com/symfony/messenger/blob/7.0/Transport/Sync/SyncTransport.php#L58

@f3l1x f3l1x merged commit 047ca78 into contributte:master Sep 4, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants