# How to shutdown a stream prefixed with a MergeHub.source without loosing elements

**URL:** <https://discuss.akka.io/t/how-to-shutdown-a-stream-prefixed-with-a-mergehub-source-without-loosing-elements/2696>\
**Category:** Akka Streams & Alpakka\
**Created:** [November 13, 2018, 9:12am UTC](https://discuss.akka.io/t/how-to-shutdown-a-stream-prefixed-with-a-mergehub-source-without-loosing-elements/2696 "2018-11-13T09:12:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hseeberger](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/hseeberger/32/2702_2.png) [@hseeberger](https://discuss.akka.io/u/hseeberger)\
**Post date:** [November 13, 2018, 9:12am UTC](https://discuss.akka.io/t/how-to-shutdown-a-stream-prefixed-with-a-mergehub-source-without-loosing-elements/2696/1 "2018-11-13T09:12:57Z")

</div>

`MergeHub.source` takes a `bufferSize` argument which cannot be zero. When using a kill switch like shown below, shutting down results in loosing the elements buffered in the source.

Are there other ways to shutdown without loosing the buffered elements than the one shown below? If not, do you think it’s possible to change the implementation of `MergeHub` to allow for `bufferSize` zero?

```scala
MergeHub
  .source[Foo](bufferSize)
  .viaMat(KillSwitches.single)(Keep.both)
  .via(processFoos)
  .runWith(Sink.ignore)

```

---

<div class="post-metadata">

**Author:** ![robgratz](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@robgratz](https://discuss.akka.io/u/robgratz)\
**Post date:** [August 31, 2020, 5:00pm UTC](https://discuss.akka.io/t/how-to-shutdown-a-stream-prefixed-with-a-mergehub-source-without-loosing-elements/2696/2 "2020-08-31T17:00:21Z")

</div>

Running into a similar situation. Any solutions or workarounds?
