# Consume-Transform-(not always)Produce with Streams

**URL:** <https://discuss.akka.io/t/consume-transform-not-always-produce-with-streams/3038>\
**Category:** Akka Streams & Alpakka\
**Tags:** java, configuration, kafka, streams\
**Created:** [December 28, 2018, 4:44pm UTC](https://discuss.akka.io/t/consume-transform-not-always-produce-with-streams/3038 "2018-12-28T16:44:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmfgameiro](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@jmfgameiro](https://discuss.akka.io/u/jmfgameiro)\
**Post date:** [December 28, 2018, 4:44pm UTC](https://discuss.akka.io/t/consume-transform-not-always-produce-with-streams/3038/1 "2018-12-28T16:44:24Z")

</div>

Hi,

I was trying to implement a Kafka consumer that could produce a new message, if required, keeping it as transactional as possible.

Hence, at the moment, I have the implementation, with the retry mechanism, displayed on the page [Transactions](https://doc.akka.io/docs/akka-stream-kafka/current/transactions.html). Then, when I execute my `map` method and I don’t get a message to send, it (obviously) throws an exception.

I’ve already tried to use the `splitWhen` method (but, as far as I can see, this only serves to process messages in parallel, it is not possible to set a different behaviour for the predicate method) and there are insufficient examples that combine the `divertTo` method and the Alpakka implementation, so I was not able create a `Graph` where it’s sole purpose was to invoke the `via` method and send that message into Kafka

Could you please help me with this issue?

Without this feature I would not be capable of detecting duplicate messages without producing any sort of message into a topic, and thus creating a lot of garbage on my Kafka servers.

Thanks for the help

btw: I’m using Java on my implementation 🙂

---

<div class="post-metadata">

**Author:** ![jmfgameiro](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@jmfgameiro](https://discuss.akka.io/u/jmfgameiro)\
**Post date:** [December 28, 2018, 5:19pm UTC](https://discuss.akka.io/t/consume-transform-not-always-produce-with-streams/3038/2 "2018-12-28T17:19:07Z")

</div>

Already solved this issue thanks to the discussion on [link](https://discuss.akka.io/t/forking-a-flow-based-on-a-boolean-condition/2234)  
😄
