@@ -696,22 +696,21 @@ of the desired grace period in seconds) in order to perform a graceful shutdown:
696
696
[program:x]
697
697
stopwaitsecs =20
698
698
699
-
700
699
Stateless Worker
701
700
~~~~~~~~~~~~~~~~
702
701
703
- PHP was designed to be stateless: everything is lost after processing an HTTP
704
- request. When you run your application in an HTTP context, you may not take care
705
- of services states that may leak services since PHP clean everything after
706
- sending the response.
702
+ PHP is designed to be stateless, there are no shared resources across different
703
+ requests. In HTTP context PHP cleans everything after sending the response, so
704
+ you can decide to not take care of services that may leak memory.
707
705
708
- Since worker run in a CLI context, you need to be careful about services state.
709
- You should avoid to put a state in a service to avoid leaking some information
710
- and/or memory from one message to another message.
706
+ On the other hand, workers usually run in long-running CLI processes, which don't
707
+ finish after processing a message. That's why you need to be careful about services
708
+ state to not leak information and/or memory from one message to another message.
711
709
712
- Some symfony services leak by nature. For example the monolog fingers crossed
713
- handler. To avoid such situations, you can configure a transport to
714
- automatically reset the container between two messages:
710
+ However, certain Symfony services, such as the Monolog
711
+ :ref: `fingers crossed handler <logging-handler-fingers_crossed >`, leak by design.
712
+ In those cases, use the ``reset_on_message `` transport option to automatically
713
+ reset the service container between two messages:
715
714
716
715
.. configuration-block ::
717
716
@@ -759,6 +758,10 @@ automatically reset the container between two messages:
759
758
;
760
759
};
761
760
761
+ .. versionadded :: 5.4
762
+
763
+ The ``reset_on_message `` option was introduced in Symfony 5.4.
764
+
762
765
.. _messenger-retries-failures :
763
766
764
767
Retries & Failures
0 commit comments