You can do both in a single application via

KStream input = builder.stream("topic");
input.to("output-1");
input.to("output-2");

In general, if you reuse a KStream or KTable and apply multiple
operators (in the example about, two `to()` operators), the input will
be duplicated and sent to each operator (ie, can also be more than two).

Note, that the data is not physically copied within the application as
only references are copied -- the records themselves are the same and
just handed in to all operators. Of course, when using `to()` the data
will be serialized in each and thus duplicated within `to()`.


-Matthias

On 7/28/17 6:33 AM, Sachin Mittal wrote:
> Hi,
> I have a multiple high level streams DSL to execute.
> 
> In first it reads from a source topic processes the data and sends the data
> to a sink.
> 
> In second it again reads from same source topic processes the data and
> sends it to a different topic.
> 
> For now these two operations are independent.
> 
> Now I can start two java applications.
> 
> But I was wondering if I can do all in single java application.
> 
> So my code is like:
> -----------------------------------------------------------------------------------------------------
> Properties props = new Properties();
> props.put(StreamsConfig.APPLICATION_ID_CONFIG, "advice");
> .....
> 
> KStreamBuilder builder = new KStreamBuilder();
> .....
> 
> //first stream
> builder.stream(Serdes.String(), valueSerde, "advice-stream")
> .......
> 
> //second steam
> builder.stream(Serdes.String(), valueSerde, "advice-stream")
> ........
> 
> 
> final KafkaStreams streams = new KafkaStreams(builder, props);
> .........
> streams.start();
> 
> Will this work?
> 
> What will be the output of the following command
> kafka-run-class.sh kafka.admin.ConsumerGroupCommand --new-consumer
> --bootstrap-server localhost:9092 --group advice --describe
> 
> Will it show me two offsets one for first stream and one for second as each
> may have different offsets.
> 
> What about rocksdb state stores?
> 
> Or this is not possible?
> 
> Thanks
> Sachin
> 

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to