Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-2278

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

    • Type: Icon: Task Task
    • Resolution: Gone away
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: Implementation
    • Labels:
      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@mongodb.com Kevin Albertson
            Reporter:
            puya@motionmetrics.com Puya Daravi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: