# mapAsync for custom stage

**URL:** <https://discuss.akka.io/t/mapasync-for-custom-stage/6609>\
**Category:** Akka Streams & Alpakka\
**Created:** [May 28, 2020, 5:26am UTC](https://discuss.akka.io/t/mapasync-for-custom-stage/6609 "2020-05-28T05:26:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebarys](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@sebarys](https://discuss.akka.io/u/sebarys)\
**Post date:** [May 28, 2020, 5:26am UTC](https://discuss.akka.io/t/mapasync-for-custom-stage/6609/1 "2020-05-28T05:26:02Z")

</div>

Hello,  
I couldn’t find clear answer to my question so I’ve decided to post it here:  
I have stream that must preserve order to ack appropriately on Kafka using `Commiter `([https://doc.akka.io/docs/alpakka-kafka/current/consumer.html#offset-storage-in-kafka-committing](https://doc.akka.io/docs/alpakka-kafka/current/consumer.html#offset-storage-in-kafka-committing)).  
This stream to some elements apply conditional flow based on predicate using custom stage described here: [https://gist.github.com/davideicardi/2a6e2a93507a731026160c2d383528ab#gistcomment-3109158](https://gist.github.com/davideicardi/2a6e2a93507a731026160c2d383528ab#gistcomment-3109158)

As applied action is async I would like to run them similar to function that could be executed in `.mapAsync` with given parallelism level but preserve elements order.

Currently my impl look like below:

```auto
kafkaMessageSource
        .via(doSthWithEachElement)
        .via(applyConditionalFlow) // here we're using custom stage that apply flow conditionally https://gist.github.com/davideicardi/2a6e2a93507a731026160c2d383528ab#gistcomment-3109158
        .map(res => res.originalMsg.committableOffset)
        .via(CommittingFlow())
        .runWith(Sink.ignore)

```

Is there a way to run `applyConditionalFlow` parallel with given by parameter parallelism level (similar to `.mapAsync`) with preserving order?
