fix: rabbitmq jobQueue expiration parameter format#25113
Conversation
|
@maliming pls review |
There was a problem hiding this comment.
Pull request overview
This PR fixes RabbitMQ per-message TTL formatting for delayed background jobs by ensuring the basicProperties.Expiration value is emitted as an integer millisecond string (RabbitMQ requires a non-negative integer string, not a floating-point representation).
Changes:
- Convert
TimeSpan.TotalMilliseconds(double) to an integer millisecond value when setting RabbitMQ messageExpiration.
There was a problem hiding this comment.
Pull request overview
This PR fixes RabbitMQ per-message TTL formatting for delayed background job messages by ensuring the Expiration property is set as an integer millisecond value (RabbitMQ requires a non-negative integer string).
Changes:
- Convert
TimeSpan.TotalMilliseconds(double) into an integer millisecond string forbasicProperties.Expiration. - Round up fractional milliseconds to avoid shortening the intended delay.
There was a problem hiding this comment.
Pull request overview
Fixes RabbitMQ per-message TTL (basicProperties.Expiration) formatting in the RabbitMQ background job queue publisher by ensuring the value is a non-negative integer string (RabbitMQ requires an integer, not a floating-point value).
Changes:
- Convert
TimeSpan.TotalMilliseconds(double) to a non-negative integer millisecond string using ceiling + long casting before publishing delayed jobs.
|
Thank you for your contribution 👍 |
Problem
TimeSpan.TotalMilliseconds is a double (e.g., 1.23), while the Expiration parameter of RabbitMQ requires a non-negative integer.
This may cause the message to not be published as expected.
https://www.rabbitmq.com/docs/3.13/ttl#per-message-ttl-in-publishers
Fix
Convert TimeSpan.TotalMilliseconds to a long value.