Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis transport - Redelivered messages should respect the original priority #2026

Merged
merged 10 commits into from
Jun 25, 2024
4 changes: 3 additions & 1 deletion kombu/transport/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,8 +789,10 @@ def _do_restore_message(self, payload, exchange, routing_key,
except KeyError:
pass
for queue in self._lookup(exchange, routing_key):
pri = self._get_message_priority(payload, reverse=False)

(pipe.lpush if leftmost else pipe.rpush)(
queue, dumps(payload),
self._q_for_pri(queue, pri), dumps(payload),
)
except Exception:
crit('Could not restore message: %r', payload, exc_info=True)
Expand Down
5 changes: 3 additions & 2 deletions t/unit/transport/test_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ def test_do_restore_message_celery(self):
"exchange": "",
"routing_key": "celery",
},
"priority": 0,
"priority": 3,
"body_encoding": "base64",
"delivery_tag": "badb725e-9c3e-45be-b0a4-07e44630519f",
},
Expand All @@ -627,7 +627,8 @@ def test_do_restore_message_celery(self):
payload, 'exchange', 'routing_key', client,
)

client.rpush.assert_called_with(queue, dumps(result_payload))
client.rpush.assert_called_with(self.channel._q_for_pri(queue, 3),
dumps(result_payload))

def test_restore_no_messages(self):
message = Mock(name='message')
Expand Down