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

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

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Gone away
    • Icon: Unknown Unknown
    • None
    • None
    • Implementation
    • None

    Description

      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.

      Attachments

        Activity

          People

            kevin.albertson@mongodb.com Kevin Albertson
            puya@motionmetrics.com Puya Daravi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: