DoctrineCloseConnectionMiddleware

final readonly class \TYPO3\CMS\Core\Messenger\Middleware\DoctrineCloseConnectionMiddleware

Implements
MiddlewareInterface

Closes the open database connections after a worker handled a received message, so the next message starts with a fresh connection in long-running "messenger:consume" workers.

Only messages consumed asynchronously by a worker (carrying a ConsumedByWorkerStamp) are handled; a synchronous dispatch never touches connections. Embedded SQLite connections are skipped (closing them is pointless and, for an in-memory database, would discard all data). Connections are closed even when handling throws, and individual connections can be excluded via BeforeMessengerDoctrineCloseEvent.

The runtime cache is flushed along with the connections: it is meant to live for one request, so a worker treats each message like a request. This also drops prepared statements cached there that belong to a closed connection.

Table of Contents

Interfaces

MiddlewareInterface

Methods

__construct()  : mixed
handle()  : Envelope

Methods

handle()

public handle(Envelope $envelope, StackInterface $stack) : Envelope

Parameters

$envelope : Envelope
$stack : StackInterface

Return values

Envelope
On this page