@@ -649,8 +649,18 @@ times:
649649 process_name =%(program_name)s_%(process_num)02d
650650
651651 Change the ``async `` argument to use the name of your transport (or transports)
652- and ``user `` to the Unix user on your server. Next, tell Supervisor to read your
653- config and start your workers:
652+ and ``user `` to the Unix user on your server.
653+
654+ If you use the Redis Transport, note that each worker needs a unique consumer
655+ name to avoid the same message being handled by multiple workers. One way to
656+ achieve this is to set an environment variable in the Supervisor configuration
657+ file, which you can then refer to in ``messenger.yaml `` (see Redis section above):
658+
659+ .. code-block :: ini
660+
661+ environment =MESSENGER_CONSUMER_NAME =%(program_name)s_%(process_num)02d
662+
663+ Next, tell Supervisor to read your config and start your workers:
654664
655665.. code-block :: terminal
656666
@@ -1380,9 +1390,13 @@ claim_interval Interval on which pending/abandoned ``60000`` (1 Minute)
13801390.. caution ::
13811391
13821392 There should never be more than one ``messenger:consume `` command running with the same
1383- config (stream, group and consumer name) to avoid having a message handled more than once.
1384- Using the ``HOSTNAME `` as the consumer might often be a good idea. In case you are using
1385- Kubernetes to orchestrate your containers, consider using a ``StatefulSet ``.
1393+ combination of ``stream ``, ``group `` and ``consumer ``, or messages could end up being
1394+ handled more than once. If you run multiple queue workers, ``consumer `` can be set to an
1395+ environment variable (like ``%env(MESSENGER_CONSUMER_NAME)% ``) set by Supervisor
1396+ (example below) or any other service used to manage the worker processes.
1397+ In a container environment, the ``HOSTNAME `` can be used as the consumer name, since
1398+ there is only one worker per container/host. If using Kubernetes to orchestrate the
1399+ containers, consider using a ``StatefulSet `` to have stable names.
13861400
13871401.. tip ::
13881402
0 commit comments