Skip to content

[Messenger] make all stamps final and mark stamp not meant to be sent #32078

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

Merged
merged 1 commit into from
Jun 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Symfony/Component/Messenger/Stamp/BusNameStamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @author Ryan Weaver <ryan@symfonycasts.com>
*/
class BusNameStamp implements StampInterface
final class BusNameStamp implements StampInterface
{
private $busName;

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Messenger/Stamp/DelayStamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* @experimental in 4.3
*/
class DelayStamp implements StampInterface
final class DelayStamp implements StampInterface
{
private $delay;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
*
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class DispatchAfterCurrentBusStamp implements StampInterface
final class DispatchAfterCurrentBusStamp implements NonSendableStampInterface
{
}
4 changes: 4 additions & 0 deletions src/Symfony/Component/Messenger/Stamp/HandledStamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
* Stamp identifying a message handled by the `HandleMessageMiddleware` middleware
* and storing the handler returned value.
*
* This is used by synchronous command buses expecting a return value and the retry logic
* to only execute handlers that didn't succeed.
*
* @see \Symfony\Component\Messenger\Middleware\HandleMessageMiddleware
* @see \Symfony\Component\Messenger\HandleTrait
*
* @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
*
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Messenger/Stamp/ReceivedStamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* @experimental in 4.3
*/
final class ReceivedStamp implements StampInterface
final class ReceivedStamp implements NonSendableStampInterface
{
private $transportName;

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Messenger/Stamp/RedeliveryStamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
* @experimental in 4.3
*/
class RedeliveryStamp implements StampInterface
final class RedeliveryStamp implements StampInterface
{
private $retryCount;
private $senderClassOrAlias;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Messenger/Stamp/SentStamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @experimental in 4.3
*/
final class SentStamp implements StampInterface
final class SentStamp implements NonSendableStampInterface
{
private $senderClass;
private $senderAlias;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @experimental in 4.3
*/
class SentToFailureTransportStamp implements StampInterface
final class SentToFailureTransportStamp implements StampInterface
{
private $originalReceiverName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @experimental in 4.3
*/
class TransportMessageIdStamp implements StampInterface
final class TransportMessageIdStamp implements StampInterface
Copy link
Contributor Author

@Tobion Tobion Jun 18, 2019

Choose a reason for hiding this comment

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

not needed to be sent but could be useful for debugging a message history (changing ID after retry)

{
private $id;

Expand Down
22 changes: 10 additions & 12 deletions src/Symfony/Component/Messenger/Tests/EnvelopeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ public function testWithoutStampsOfType()
{
$envelope = new Envelope(new DummyMessage('dummy'), [
new ReceivedStamp('transport1'),
new DelayStamp(5000),
new DummyExtendsDelayStamp(5000),
new DummyImplementsFooBarStampInterface(),
new DummyExtendsFooBarStamp(),
new DummyImplementsFooBarStamp(),
]);

$envelope2 = $envelope->withoutStampsOfType(DummyNothingImplementsMeStampInterface::class);
Expand All @@ -66,12 +65,11 @@ public function testWithoutStampsOfType()
$envelope3 = $envelope2->withoutStampsOfType(ReceivedStamp::class);
$this->assertEmpty($envelope3->all(ReceivedStamp::class));

$envelope4 = $envelope3->withoutStampsOfType(DelayStamp::class);
$this->assertEmpty($envelope4->all(DelayStamp::class));
$this->assertEmpty($envelope4->all(DummyExtendsDelayStamp::class));
$envelope4 = $envelope3->withoutStampsOfType(DummyImplementsFooBarStamp::class);
$this->assertEmpty($envelope4->all(DummyImplementsFooBarStamp::class));
$this->assertEmpty($envelope4->all(DummyExtendsFooBarStamp::class));

$envelope5 = $envelope4->withoutStampsOfType(DummyFooBarStampInterface::class);
$this->assertEmpty($envelope5->all(DummyImplementsFooBarStampInterface::class));
$envelope5 = $envelope3->withoutStampsOfType(DummyFooBarStampInterface::class);
$this->assertEmpty($envelope5->all());
}

Expand Down Expand Up @@ -118,15 +116,15 @@ public function testWrapWithEnvelope()
}
}

class DummyExtendsDelayStamp extends DelayStamp
{
}
interface DummyFooBarStampInterface extends StampInterface
{
}
interface DummyNothingImplementsMeStampInterface extends StampInterface
{
}
class DummyImplementsFooBarStampInterface implements DummyFooBarStampInterface
class DummyImplementsFooBarStamp implements DummyFooBarStampInterface
{
}
class DummyExtendsFooBarStamp extends DummyImplementsFooBarStamp
{
}