[ChangeStream] Why does iterating change stream block and how to avoid it

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Gone away
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: Implementation
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Hello,

      I am trying to use change streams and this code snippet is blocking:

      for (const auto& event : stream)
      {
          handleEvent(event);
      }
      

      I run the above code periodically on different streams. But I see that stream iteration blocks when it is empty and I am not able to break out of this loop if that happens. Why is that the case? How can I read all available events in the stream and not be blocked? I cannot use a break; since I don't know before reading the stream how many events are in there.

              Assignee:
              Kevin Albertson
              Reporter:
              Puya Daravi
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: