Skip to content

Consumer<Dedup>: publishing_id incorrect #233

Closed
@medigor

Description

@medigor

Describe the bug

Publishing_id calculated incorrectly.

Reproduction steps

  1. 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions