0

i want to do join between two kafka topics in one Datastream.

In fact the two datastream must have the same id to make the join. Event are the data coming from the sensors and rule contains rules that will be checked with the CEP(coming from User Interface).

Here is my test but it does not work, can anyone help me please ?

DataStream<Object> evtAndRule=inputEventStream.join(rulesStream)
            .where(new KeySelector<TrackEvent, Object>() {
                @Override
                public Object getKey(Event event) throws Exception {
                    return event.getId();
                }
            }).equalTo(new KeySelector<RulesEvent, Object>() {
                @Override
                public Object getKey(RulesEvent rulesEvent) throws Exception {
                    return rulesEvent.getId();
                }
            }).window(TumblingTimeWindows.of(Time.of(10, TimeUnit.SECONDS)))
            .apply(new FlatJoinFunction<TrackEvent, RulesEvent, Object>() {
                @Override
                public void join(TrackEvent trackEvent, RulesEvent rulesEvent, Collector<Object> collector) throws Exception {
            ....

                }
            });

1 Answers1

0

I tried this but I do not know how to retrieve the desired rule and if this is the best solution

        DataStream<Tuple2<Event , RulesEvent>> evtAndRule= inputEventStream.map(new MapFunction<Event , Tuple2<Event , RulesEvent>>() {
        @Override
        public Tuple2<Event , RulesEvent> map(final Event event) throws Exception {

            return new Tuple2<Event , RulesEvent>(event, new RulesEvent());
        }
    });