Code Monkey home page Code Monkey logo

Comments (5)

bbejeck avatar bbejeck commented on July 17, 2024

Hi @imperio-wxm,

Sorry for the seriously delayed response. The best way for you to do this is with KStream#branch or in the ProcessorAPI where you can forward to specific child nodes by name. Either way, the output topics need to be defined in the topology ahead of time. Let me know if you need more info.

HTH
Bill

from kafka-streams.

psawmora avatar psawmora commented on July 17, 2024

@bbejeck What if we want to create a new record in addition to what we have and forward both to different child processors ? It's like,

 new_record = createNewRecord(old_record);
 context.forward(original_record, to(child_1));
 context.forward(new_record, to(child_2));

Is this a good practice ?

from kafka-streams.

HungUnicorn avatar HungUnicorn commented on July 17, 2024

I think that's the API(Kafka) restriction and wouldn't be a good practice.
Instead of doing the above, you could have two topologies as children, and let them obtain the output of old_record

ParentTopo -> NewRecordTopo(createNewRecord) -> sink1
           -> OldRecordTopo -> sink2

This could achieve your goal. @bbejeck maybe could give more insight about why Processor context cannot forward to two processors.

from kafka-streams.

imperio-wxm avatar imperio-wxm commented on July 17, 2024

Hi, @bbejeck
Sorry, my reply is late.

I think @psawmora is right.

I do like this, and it works, for a long time I didn't find any problems:

switch(type) {
     case type1:
          context.forward(newKey1, newValue1, TOPIC_1);
          break;
     case type2:
          context.forward(newKey2, newValue2, TOPIC_2);
          break:
     .......
}

I wrote a generic Processor to specifically split the topic. Topological image of a tree.
But source topic can only be one.
Is this a good practice ?

from kafka-streams.

psawmora avatar psawmora commented on July 17, 2024

@imperio-wxm

But have you tried forwarding the same flow to two different processors at the same time ?

from kafka-streams.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.