@@ -165,7 +165,7 @@ private function handleMessage(Envelope $envelope, string $transportName): void
165165 if (!$ acked && !$ noAutoAckStamp ) {
166166 $ this ->acks [] = [$ transportName , $ envelope , $ e ];
167167 } elseif ($ noAutoAckStamp ) {
168- $ this ->unacks [$ noAutoAckStamp ->getHandlerDescriptor ()->getBatchHandler ()] = [$ envelope ->withoutAll (AckStamp::class), $ transportName ];
168+ $ this ->unacks [$ noAutoAckStamp ->getHandlerDescriptor ()->getBatchHandler ()] = [$ envelope ->withoutAll (AckStamp::class), $ transportName, & $ acked ];
169169 }
170170
171171 $ this ->ack ();
@@ -254,13 +254,23 @@ private function flush(bool $force): bool
254254 $ this ->unacks = new \SplObjectStorage ();
255255
256256 foreach ($ unacks as $ batchHandler ) {
257- [$ envelope , $ transportName ] = $ unacks [$ batchHandler ];
257+ [$ envelope , $ transportName, $ acked ] = $ unacks [$ batchHandler ];
258258 try {
259+ $ e = null ;
259260 $ this ->bus ->dispatch ($ envelope ->with (new FlushBatchHandlersStamp ($ force )));
260261 unset($ unacks [$ batchHandler ], $ batchHandler );
261262 } catch (\Throwable $ e ) {
262263 $ envelope = $ envelope ->withoutAll (NoAutoAckStamp::class);
263264 $ this ->acks [] = [$ transportName , $ envelope , $ e ];
265+ continue ;
266+ }
267+
268+ $ noAutoAckStamp = $ envelope ->last (NoAutoAckStamp::class);
269+
270+ if (!$ acked && !$ noAutoAckStamp ) {
271+ $ this ->acks [] = [$ transportName , $ envelope , $ e ];
272+ } elseif ($ noAutoAckStamp ) {
273+ $ this ->unacks [$ noAutoAckStamp ->getHandlerDescriptor ()->getBatchHandler ()] = [$ envelope ->withoutAll (AckStamp::class), $ transportName , &$ acked ];
264274 }
265275 }
266276
0 commit comments