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

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

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Unknown
    • Resolution: Gone away
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Implementation
    • Labels:
      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

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

              Dates

              Created:
              Updated:
              Resolved: