0

I have a game for social networks. In this game every player can get some bonus score for any action that he makes. All actions are publising to rabbit Mq in json like {"action": "register", "player_id": 10, "action_id": 100}.

I want to create 10 parallel workers to consume and proceed this actions. I have a strict condition that all events for player must be in the same queue. It means that I can't proceed events for player in parallel.

What is the right way to distribute my events to parallel queues?

I've already tried to add topic based on player_id % queues_count (remainder of the division) like event_to_queue_9, event_to_queue_2 and so on. In this case I have two or three overflowed queues and others are empty. Is there better way to solve my problem?

marv255
  • 808
  • 6
  • 19

1 Answers1

0

If you don't want to provide the sharded routing key from the client (which I'd argue that's not optimal), you may want to have a look to RabbitMQ Consistent Hash Exchange

José M
  • 3,294
  • 1
  • 14
  • 16