Flink newbie here.
I have a local setup where Flink processes JSON events generated by Debezium. The idea is to monitor conversations happening between a customer support agent and a customer. If the customer support agent does not reply to a message within a certain time frame, I'd like to raise an alert.
My Flink CEP code looks as follows:
// We create a watermark strategy
WatermarkStrategy<MessageEvent> watermarkStrategy = WatermarkStrategy
.<MessageEvent>forMonotonousTimestamps()
.withTimestampAssigner((event, ts) -> event.getPayload().getAfter().getCreatedAt().longValue());
// We get our inputs here
KafkaSource<String> msgTopic = Sources.kafkaSource("message", "flink");
DataStream<String> input = env.fromSource(msgTopic, WatermarkStrategy.noWatermarks(), "Message Source");
// Convert the Debezium payload into MessageEvent and assign watermarks
// Partition by thread ID
DataStream<MessageEvent> msgStream = input.map(new MessageMapper())
.assignTimestampsAndWatermarks(watermarkStrategy)
.keyBy(msg -> msg.getPayload().getAfter().getThreadId());
Pattern<MessageEvent, ?> pattern = Pattern.<MessageEvent>begin("start", AfterMatchSkipStrategy.skipPastLastEvent())
.where(new MessageEventDirectionFilter("INCOMING"))
.oneOrMore()
.greedy()
.notNext("end")
.where(new MessageEventDirectionFilter("OUTGOING"))
.within(Time.seconds(10));
CEP.pattern(msgStream, pattern)
.inEventTime()
.process(new IdleConversationProcessFunction())
.print();
INCOMING
messages are those which are sent by the customer where as OUTGOING
messages are the ones sent by the support agent. This is what I am trying to capture. I can see records being sent to the STDOUT operator but nothing shows up in the task manager logs.
Why does the pattern defined not match?