Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitce2b086

Browse files
committed
minor#14888 [Messenger] More on unique Redis consumer names (danmichaelo)
This PR was merged into the 5.2 branch.Discussion----------[Messenger] More on unique Redis consumer namesI managed to miss the warning that the (strem,group,consumer) combination must be unique. I think it would make it less easy to miss if it was also mentioned in the Supervisor section, so I've tried to add a mention of it there. I also expanded the original warning block a bit.There are many different combinations of transports and ways to manage workers, so I understand that the docs should not delve too deep into each one, but I think it's worthwhile to cover the Redis + Supervisor combo quite well, since it's one of the easier combinations to get started with, which also can work really well. Let me know what you think.Related:#11869 #35358Commits-------e73e923 [Messenger] More on unique Redis consumer names
2 parents2ca4b0a +e73e923 commitce2b086

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

‎messenger.rst

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,18 @@ times:
626626
process_name=%(program_name)s_%(process_num)02d
627627
628628
Change the ``async`` argument to use the name of your transport (or transports)
629-
and ``user`` to the Unix user on your server. Next, tell Supervisor to read your
629+
and ``user`` to the Unix user on your server.
630+
631+
If you use the Redis Transport, note that each worker needs a unique consumer name to
632+
avoid the same message being handled by multiple workers. One way to achieve this is
633+
to set an environment variable in the Supervisor configuration file, which you can
634+
then refer to in `messenger.yaml` (see Redis section above):
635+
636+
..code-block::ini
637+
638+
environment=MESSENGER_CONSUMER_NAME=%(program_name)s_%(process_num)02d
639+
640+
Next, tell Supervisor to read your
630641
config and start your workers:
631642

632643
..code-block::terminal
@@ -1239,9 +1250,13 @@ claim_interval Interval on which pending/abandoned ``60000`` (1 Minute)
12391250
..caution::
12401251

12411252
There should never be more than one ``messenger:consume`` command running with the same
1242-
config (stream, group and consumer name) to avoid having a message handled more than once.
1243-
Using the ``HOSTNAME`` as the consumer might often be a good idea. In case you are using
1244-
Kubernetes to orchestrate your containers, consider using a ``StatefulSet``.
1253+
combination of ``stream``, ``group`` and ``consumer``, or messages could end up being
1254+
handled more than once. If you run multiple queue workers, ``consumer` can be set to an
1255+
environment variable (like ``%env(MESSENGER_CONSUMER_NAME)%`)` set by Supervisor
1256+
(example below) or whatever service used to manage the worker processes.
1257+
In a container environment, the ``HOSTNAME`` can be used as the consumer name, since
1258+
there is only one worker per container/host. If using Kubernetes to orchestrate the
1259+
containers, consider using a ``StatefulSet`` to have stable names.
12451260

12461261
..tip::
12471262

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp