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.
707
707
708
708
On the other hand, workers usually sequentially process messages in long-running CLI processes, which don't
709
709
finish 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.
711
712
712
713
However, certain Symfony services, such as the Monolog
713
714
:ref: `fingers crossed handler <logging-handler-fingers_crossed >`, leak by design.
714
715
That'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
+
715
720
If you don't want to reset the container, add the ``--no-reset `` option when
716
721
running the ``messenger:consume `` command.
717
722
You can’t perform that action at this time.
0 commit comments