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

Commit7822b3c

Browse files
committed
bug#32027 [Messenger] Remove DispatchAfterCurrentBusStamp when message is put on internal queue (Nyholm)
This PR was merged into the 4.3 branch.Discussion----------[Messenger] Remove DispatchAfterCurrentBusStamp when message is put on internal queue| Q | A| ------------- | ---| Branch? | 4.3| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#32009| License | MIT| Doc PR |This willfix#32009.Thank you@brpauwels for the report.I consider it safe to remove the `DispatchAfterCurrentBusStamp` because its meaning disappear after we handled the "current bus".T0: We add the stampT1: We put the envelope on an internal queue in `DispatchAfterCurrentBusMiddleware`T2: We handle the current bus.T3: We start processing our internal queue.At T3 there we are "after current bus", that is why we dont need the stamp any more.Commits-------91f1680 [Messenger] Remove DispatchAfterCurrentBusStamp when message is put on internal queue
2 parents3634390 +91f1680 commit7822b3c

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

‎src/Symfony/Component/Messenger/Middleware/DispatchAfterCurrentBusMiddleware.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ final class QueuedEnvelope
112112

113113
publicfunction__construct(Envelope$envelope,StackInterface$stack)
114114
{
115-
$this->envelope =$envelope;
115+
$this->envelope =$envelope->withoutAll(DispatchAfterCurrentBusStamp::class);
116116
$this->stack =$stack;
117117
}
118118

‎src/Symfony/Component/Messenger/Tests/Middleware/DispatchAfterCurrentBusMiddlewareTest.php‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,53 @@ public function testThrowingEventsHandlingWontStopExecution()
9999
$messageBus->dispatch($message);
100100
}
101101

102+
publicfunctiontestHandleDelayedEventFromQueue()
103+
{
104+
$message =newDummyMessage('Hello');
105+
$event =newDummyEvent('Event on queue');
106+
107+
$middleware =newDispatchAfterCurrentBusMiddleware();
108+
$commandHandlingMiddleware =$this->createMock(MiddlewareInterface::class);
109+
$eventHandlingMiddleware =$this->createMock(MiddlewareInterface::class);
110+
111+
// This bus simulates the bus that are used when messages come back form the queue
112+
$messageBusAfterQueue =newMessageBus([
113+
// Create a new middleware
114+
newDispatchAfterCurrentBusMiddleware(),
115+
$eventHandlingMiddleware,
116+
]);
117+
118+
$fakePutMessageOnQueue =$this->createMock(MiddlewareInterface::class);
119+
$fakePutMessageOnQueue->expects($this->any())
120+
->method('handle')
121+
->with($this->callback(function ($envelope)use ($messageBusAfterQueue) {
122+
// Fake putting the message on the queue
123+
// Fake reading the queue
124+
// Now, we add the message back to a new bus.
125+
$messageBusAfterQueue->dispatch($envelope);
126+
127+
returntrue;
128+
}))
129+
->willReturnArgument(0);
130+
131+
$eventBus =newMessageBus([
132+
$middleware,
133+
$fakePutMessageOnQueue,
134+
]);
135+
136+
$messageBus =newMessageBus([
137+
$middleware,
138+
newDispatchingMiddleware($eventBus, [
139+
newEnvelope($event, [newDispatchAfterCurrentBusStamp()]),
140+
]),
141+
$commandHandlingMiddleware,
142+
]);
143+
144+
$this->expectHandledMessage($commandHandlingMiddleware,0,$message);
145+
$this->expectHandledMessage($eventHandlingMiddleware,0,$event);
146+
$messageBus->dispatch($message);
147+
}
148+
102149
/**
103150
* @param MiddlewareInterface|MockObject $handlingMiddleware
104151
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp