Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Messenger] Envelope-aware middleware is never called with a message#27841

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sroze merged 1 commit intosymfony:masterfromCydonia7:envelope-aware-middleware
Jul 19, 2018
Merged

[Messenger] Envelope-aware middleware is never called with a message#27841

sroze merged 1 commit intosymfony:masterfromCydonia7:envelope-aware-middleware
Jul 19, 2018

Conversation

@Cydonia7
Copy link
Contributor

@Cydonia7Cydonia7 commentedJul 4, 2018
edited by ogizanagi
Loading

QA
Branch?master
Bug fix?no
New feature?no
BC breaks?yes
Deprecations?no
Tests pass?yes
Fixed ticketsno
LicenseMIT
Doc PRno

Messenger components middlewares implementingSymfony\Component\Messenger\EnvelopeAwareInterface receive in their handle method an instance ofSymfony\Component\Messenger\Envelope, not a message.

To better reflect the expected usage, I've updated the unit tests for the message middleware and fixed the code accordingly.

Copy link
Contributor

@srozesroze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can you rebase on 4.1 and change your PR's base as well?

* {@inheritdoc}
*/
publicfunctionhandle($message,callable$next)
publicfunctionhandle($envelope,callable$next)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can you add a@param Envelope $envelope above the{@inheritdoc}? I think that this would be better to explicit it's an Envelope.

@Cydonia7Cydonia7 changed the base branch frommaster to4.1July 4, 2018 12:20
@Cydonia7
Copy link
ContributorAuthor

Cydonia7 commentedJul 4, 2018
edited
Loading

@sroze Comments addressed. I think failures on Appveyor are not related to this PR.

}

/**
* @param Envelope $envelope

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Since the component is experimental, we can turn this to a real type hint on master at least?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

There is a PR for this (#27322) but I don't think that it's a good idea. At all.

publicfunctionhandle($message,callable$next)
publicfunctionhandle($envelope,callable$next)
{
$envelope = Envelope::wrap($message);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Could this introduce any BC break?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nop, becauseEnvelopeAwareInterface, the contract is that it gets anEnvelope.

@ogizanagi
Copy link
Contributor

Just to be sure: this is not fixing a bug at all, just removing support of a message inEnvelopeAwareInterface middlewares, right?

Our bus implementation ensures it always receives the Envelope, it's true, but nothing in the design really allows a stronger enforcement here. Seesymfony/symfony-docs#9757 (comment) discussion and#27322 already mentioned above.
(Note I'm not against this PR, but still proves to me#27322 would be a better design).

Also, theValidationMiddleware could benefit from similar changes.

yceruto reacted with thumbs up emoji

@sroze
Copy link
Contributor

Just to be sure: this is not fixing a bug at all, just removing support of a message in EnvelopeAwareInterface middlewares, right?

You are right actually. Maybe we should keep it that way to ensure the middlewares could be used with another bus implementation that does not support theEnvelopeAwareInterface. My 👍 is for this change, so we clarify that this handling ofEnvelopeAwareInterface is part of theMessageBusInterface (we could add a comment to it).

@Cydonia7 As per@ogizanagi's comment, can you update theValidationMiddleware file as well?

@ogizanagiogizanagi removed the Bug labelJul 8, 2018
@ogizanagi
Copy link
Contributor

ogizanagi commentedJul 8, 2018
edited
Loading

So, this cannot be merged in 4.1 as not acceptable in a patch release to me. PR should target and be rebased on master and removal of the support of messages not wrapped in an Envelope be mentioned in the UPGRADE file. Also I'd suggest to removeEnvelope::wrap as inb3a6768 as the only reason it exists in core was for this (I'll cherry-pick the commit later).

@Cydonia7
Copy link
ContributorAuthor

@ogizanagi@sroze I've rebased on master and adapted theValidationMiddleware in the same way.

@fabpot
Copy link
Member

@ogizanagi Can you review this PR please?

@fabpotfabpot removed this from the4.1 milestoneJul 19, 2018
Copy link
Contributor

@ogizanagiogizanagi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

That's ok with latest changes 👍
But we miss a mention for the BC break in the UPGRADE file.

@Cydonia7
Copy link
ContributorAuthor

@ogizanagi I just added a note in the UPGRADE file for 4.2

@fabpot I see you've changed the milestone to 4.1 and next, does this mean this will be inside the next patch or next minor? (If it's patch, then I should move the UPGRADE note)

@sroze
Copy link
Contributor

@Cydonia7 it means it goes to the next release. So 4.2.

Messenger
---------

* The`Symfony\Component\Messenger\Middleware\ValidationMiddleware` and`Symfony\Component\Messenger\Asynchronous\Middleware\SendMessageMiddleware` do not support messages in their`handle` method anymore.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We need more than this. I suggest adding something like:

...because they implement theEnvelopeAwareInterface. You need to give them an instance of theEnvelope object, wrapping your message. You can useEnvelope::wrap($message).

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks for the review, I just added it.

Messenger
---------

* The`Symfony\Component\Messenger\Middleware\ValidationMiddleware` and`Symfony\Component\Messenger\Asynchronous\Middleware\SendMessageMiddleware` do not support messages in their`handle` method anymore because they implement the`EnvelopeAwareInterface`. You need to give them an instance of the`Envelope` object, wrapping your message. You can use Envelope::wrap($message).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Addaround theEnvelope::wrap` example.

Also, I think that I'd phrase it like:

Thehandle method of the X and Y middleware now requires anEnvelope object to be given (because they implement theEnvelopeAwareInterface. When using these middleware with the provided MessageBus, you will not have to do anything. If you use the middleware any other way, you can useEnvelope::wrap($message) to create an envelope for your message.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It looks a lot better like that.

@sroze
Copy link
Contributor

Thank you@Cydonia7.

@srozesroze merged commit9488e2a intosymfony:masterJul 19, 2018
sroze added a commit that referenced this pull requestJul 19, 2018
…th a message (Cydonia7)This PR was merged into the 4.2-dev branch.Discussion----------[Messenger] Envelope-aware middleware is never called with a message| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | no| BC breaks?    | yes     <!-- seehttps://symfony.com/bc -->| Deprecations? | no| Tests pass?   | yes| Fixed tickets | no| License       | MIT| Doc PR        | noMessenger components middlewares implementing `Symfony\Component\Messenger\EnvelopeAwareInterface` receive in their handle method an instance of `Symfony\Component\Messenger\Envelope`, not a message.To better reflect the expected usage, I've updated the unit tests for the message middleware and fixed the code accordingly.Commits-------9488e2a [Messenger] Envelope-aware middleware is never called with a message
@Cydonia7Cydonia7 deleted the envelope-aware-middleware branchJuly 19, 2018 11:27
@nicolas-grekasnicolas-grekas modified the milestones:next,4.2Nov 1, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@dunglasdunglasAwaiting requested review from dunglas

@lyrixxlyrixxAwaiting requested review from lyrixx

+2 more reviewers

@srozesrozesroze approved these changes

@ogizanagiogizanagiogizanagi approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.2

Development

Successfully merging this pull request may close these issues.

6 participants

@Cydonia7@ogizanagi@sroze@fabpot@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp