@@ -619,7 +619,17 @@ times:
619
619
process_name =%(program_name)s_%(process_num)02d
620
620
621
621
Change the ``async `` argument to use the name of your transport (or transports)
622
- and ``user `` to the Unix user on your server. Next, tell Supervisor to read your
622
+ and ``user `` to the Unix user on your server.
623
+
624
+ If you use the Redis Transport, note that each worker needs a unique consumer name to
625
+ avoid the same message being handled by multiple workers. One way to achieve this is
626
+ to set an environment variable in the Supervisor configuration file, which you can
627
+ then refer to in `messenger.yaml ` (see Redis section above):
628
+
629
+ .. code-block :: ini
630
+ environment =MESSENGER_CONSUMER_NAME =%(program_name)s_%(process_num)02d
631
+
632
+ Next, tell Supervisor to read your
623
633
config and start your workers:
624
634
625
635
.. code-block :: terminal
@@ -1209,9 +1219,13 @@ claim_interval Interval on which pending/abandoned ``60000`` (1 Minute)
1209
1219
.. caution ::
1210
1220
1211
1221
There should never be more than one ``messenger:consume `` command running with the same
1212
- config (stream, group and consumer name) to avoid having a message handled more than once.
1213
- Using the ``HOSTNAME `` as the consumer might often be a good idea. In case you are using
1214
- Kubernetes to orchestrate your containers, consider using a ``StatefulSet ``.
1222
+ combination of ``stream ``, ``group `` and ``consumer ``, or messages could end up being
1223
+ handled more than once. If you run multiple queue workers, ``consumer` can be set to an
1224
+ environment variable (like ``%env(MESSENGER_CONSUMER_NAME)%`)` set by Supervisor
1225
+ (example below) or whatever service used to manage the worker processes.
1226
+ In a container environment, the ``HOSTNAME `` can be used as the consumer name, since
1227
+ there is only one worker per container/host. If using Kubernetes to orchestrate the
1228
+ containers, consider using a ``StatefulSet `` to have stable names.
1215
1229
1216
1230
.. tip ::
1217
1231
0 commit comments