Instead of doing this explicitly maybe we could use a BlockingQueuedConnection for this? Not sure if it's worth it though but splitting the logic up makes the code makes the control flow harder to understand.