Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventPosition::SequenceNumber seems to still start from the beginning #11

Closed
jackgerrits opened this issue Aug 30, 2023 · 2 comments
Closed

Comments

@jackgerrits
Copy link

Sorry I don't have a self contained repro on this one but I call read_events_from_partition and pass EventPosition::earliest() and read a few events. I then save the sequence number to start from and start a new reading stream but this time using EventPosition::from_sequence_number(pos, false).

async fn get_start_position(partition_id: &str) -> EventPosition {
    // Some logic to determine the start pos
    let starting_pos: i64 = get_sequence_number_to_start_from(&partition_id);
    match starting_pos {
        -1 => EventPosition::earliest(),
        pos => EventPosition::from_sequence_number(pos, false),
    }
}

// ...


let starting_pos = get_start_position(&checkpoint, &partition_id).await;
// ...
let stream = client
                .read_events_from_partition(
                    &partition_id,
                    starting_pos,
                    ReadEventOptions::default()
                )
                .await;

The behavior I am seeing is that even though I am passing an EventPosition that is later than the oldest event I am still reading from the oldest event. (The same event as I first received when I starting reading from `EventPosition::earliest()``

Am I misconfiguring something perhaps?

@minghuaw
Copy link
Owner

minghuaw commented Aug 31, 2023

Hi @jackgerrits

I am not able to reproduce this behaviour. I have added a simple example consumer_read_from_position.rs which basically let the consumer read 30 events from the beginning, records the last known sequence number (ie. the sequence number of the 30th event), closes the stream, then call read_events_from_partition() again but with the recorded last known sequence number, and it seems to work just as expected. The partition was first populated with 300 events with the event_hub_producer_example.rs which contains a monotonically increasing number.

I have also tried closing the consumer client entirely and create a new one, which also works as expected. Could you let me know more about your configuration?

@jackgerrits
Copy link
Author

Apologies, my repro is really vague. I'll spend some more time seeing if the issue is in my code. I'll close this and reopen if I have a clearer description.

@minghuaw minghuaw transferred this issue from minghuaw/azure-sdk-for-rust Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants