File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -707,11 +707,16 @@ you can decide to not take care of services that may leak memory.
707707
708708On the other hand, workers usually sequentially process messages in long-running CLI processes, which don't
709709finish after processing a single message. That's why you must be careful about service
710- states to prevent information and/or memory leakage.
710+ states to prevent information and/or memory leakage as Symfony will inject the same instance of a
711+ service, preserving the internal state of the service between messages.
711712
712713However, certain Symfony services, such as the Monolog
713714:ref: `fingers crossed handler <logging-handler-fingers_crossed >`, leak by design.
714715That's why Symfony automatically resets the service container between two messages.
716+ If a service is not stateless and you want to reset its properties after each message, then
717+ the service must implement :class: `Symfony\\ Contracts\\ Service\\ ResetInterface ` where you can reset the
718+ properties in the ``reset() `` method.
719+
715720If you don't want to reset the container, add the ``--no-reset `` option when
716721running the ``messenger:consume `` command.
717722
You can’t perform that action at this time.
0 commit comments