How to get all outputtags from SingleOutputStreamOperator and process them separately for all of different DataStream

Viewed 27

I am new to Flink i am doing of pattern evaluation using Flink CEP, as shown below,In the ProcessFunction, it is judged to store different types of AlertEvent in different OutputTags. There are many event types, and the number of events types grows as it runs

SingleOutputStreamOperator<AlertEvent, AlertEvent> outputStream = dataStream.process(new ProcessFunction<AlertEvent, AlertEvent>() {
    @Override
    public void processElement(AlertEvent event, Context ctx, Collector<AlertEvent> out) throws Exception {
            //There are many event types, and the number of events types grows as it runs

            ctx.output(new OutputTag<AlertEvent>(event.getType()), event);
        
    }
})

then, I use the getSideOutput method to get the data of different OutputTags, like this:

outputStream.getSideOutput(new OutputTag<AlertEvent>(type1)).print();
outputStream.getSideOutput(new OutputTag<AlertEvent>(type2)).print();
outputStream.getSideOutput(new OutputTag<AlertEvent>(type3)).print();

It looks ok,but when I write the code, I don't know how many output tags there will be.

How can I get all output tags from outputStream and process them separately for all of different DataStream<AlertEvent>, after reading flink's documentation for a long time, I can't find the corresponding API which can traverse the outputTags.

If some one can answer it will be useful for further references to others also.

0 Answers
Related