DoctrineCloseConnectionMiddleware
final readonly class \
- 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.
Internal
not part of TYPO3 Core API
Table of Contents
Interfaces
- MiddlewareInterface
Methods
- __construct() : mixed
- handle() : Envelope
Methods
__construct()
public
__construct(ConnectionPool $connectionPool, EventDispatcherInterface $eventDispatcher, CacheManager $cacheManager) : mixed
Parameters
- $connectionPool : ConnectionPool
- $eventDispatcher : EventDispatcherInterface
- $cacheManager : CacheManager
handle()
public
handle(Envelope $envelope, StackInterface $stack) : Envelope
Parameters
- $envelope : Envelope
- $stack : StackInterface