Quantcast
Channel: Akka Libraries - Discussion Forum for Akka technologies
Viewing all articles
Browse latest Browse all 1367

How to detect that a consumer has disconnected from a stream

$
0
0

Given the following

    val ((queue, ks), source) =
      Source
        .queue[MyThing](queueSize, OverflowStrategy.dropHead)
        .viaMat(KillSwitches.single)(Keep.both)
        .preMaterialize()

How can I detect when the consumer of the source has disconnected so that I can clean up any resources that were created to serve this stream?

I tried adding

stream.watchTermination() { (_, done) =>
      done.onComplete { _ =>
        // cleanup
      }
      NotUsed
    }

but it is never invoked

2 posts - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 1367

Trending Articles