1

Post reading messages one by one into the KStreams, we apply some filtering and transformation and then produce it to the SINK topic. Now, our scenario transformation is little complex task.

Is there a way to make this portion of work (i.e. filtering + transformation + production to SINK topic) can be made Transactional i.e. Whether all parts happens or nothing at all ?

KStream<String, Customer> transformedStream = sourceKafkaStream
                .mapValues(cust -> {
                    try {
                        logger.info("Hitting to the downstream to fetch additional information, will take few seconds.");
                        Thread.sleep(7000);
                        return RecordEnrichmentAndTransformationBuilder.enrichTheCustomer(cust);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    return cust;
                });
                .to('newTopic1', Produced.with(AppSerdes.String(), AppSerdes.serdeForEnrichedCustomer()));

Appreciate the response on this folks..

Bartosz Wardziński
  • 6,185
  • 1
  • 19
  • 30
Aditya Goel
  • 201
  • 1
  • 15

0 Answers0