rabbitmq / amqp091-go

An AMQP 0-9-1 Go client maintained by the RabbitMQ team. Originally by @streadway: `streadway/amqp`
Other
1.49k stars 135 forks source link

Documenting Publishing.Expiration usage #232

Closed niksteff closed 10 months ago

niksteff commented 10 months ago

So this one got me good on a really nasty bug from my side. I was using the pkg to publish big batches of messages to a queue. When reading the source code it was not clear to me the value was used as milliseconds. I assumed wrongly if the value is 0 the message will not expire. I assumed this because 0 would be the nil value for a go int. This assumption was painfully wrong - which lead to all messages not immediately retrieved by the consumer to get rightfully deleted. I wanted to spare others from the same mistake.

I am perfectly aware the rabbit mq documentation states the usage here: https://www.rabbitmq.com/ttl.html#per-message-ttl-in-publishers

But I think a little more documentation in the code and some clarification can prevent others from making the same mistake. I also provided two constants for the field that further elaborate on the usage and should explain it in its entirety. They are not needed but so are the DeliveryMode constants (Transient, Persistent). If this is not wanted please provide feedback and I will refine the PR.

Best regards and thank you all a lot for your work on this client!

Zerpet commented 10 months ago

I will merge after CI passes since we have a restriction in place for merging 🔒