Description
Describe the bug
Publishing_id calculated incorrectly.
Reproduction steps
- run next code 2 times:
let mut producer = environment
.producer()
.name("producer1")
.build(stream)
.await?;
for _ in 0..2 {
producer
.send(message.clone(), |result| async {
let id = result.unwrap().publishing_id();
println!("publishing_id: {id}");
})
.await?;
}
sleep(Duration::from_secs(1)).await;
first run result:
publishing_id: 9004087
publishing_id: 9004086
second run result:
publishing_id: 9004088
publishing_id: 9004087
Expected behavior
Publishing_id must be unique
Additional context
Error in https://github.com/rabbitmq/rabbitmq-stream-rust-client/blob/main/src/producer.rs:
let publishing_id = match message.publishing_id() {
Some(publishing_id) => *publishing_id,
None => self.0.publish_sequence.fetch_add(1, Ordering::Relaxed),
};
fetch_add
returning the previous value!