py-amqp icon indicating copy to clipboard operation
py-amqp copied to clipboard

X-Delay header is mangled on receipt (signed/unsigned integer issue)

Open cjsoftuk opened this issue 1 year ago • 1 comments

As per https://www.rabbitmq.com/blog/2015/04/16/scheduling-messages-with-rabbitmq, if you use the delayed exchange, and set the x-delay header, the headers when it is received by the application on the other end (also using py-amqp), the header becomes mangled as it is negated when it is sent via the delayed exchange to confirm it was delayed (see https://www.rabbitmq.com/blog/2015/04/16/scheduling-messages-with-rabbitmq#checking-if-a-message-was-delayed).

Take the following headers on a message (for example):

{'x-retries': 3, 'x-delay': 1000}

Upon receipt on the other side of RabbitMQ, py-amqp shows these as

{'x-delay': 18446744073709550616, 'x-retries': 3}

X-Delay is, indeed, -1000, if you look at it as a signed integer. It appears the library sees it as an unsigned integer and therefore produces a potentially catastrophically incorrect answer.

cjsoftuk avatar Oct 29 '24 12:10 cjsoftuk

would you mind coming with a fix with proper tests?

auvipy avatar Mar 19 '25 10:03 auvipy