Jerome Li
Jerome Li

Reputation: 176

Flink set timer on non keyed stream

Can Flink set timer on the non-keyed stream?

ProcessAllWindowFunctionis a good option. But it cannot scale up the parallelism. It has to be 1.

I am looking for such non-keyed process function that can set a timer.

Upvotes: 2

Views: 859

Answers (2)

Bosco Han
Bosco Han

Reputation: 113

you could keyBy(_ => None) or keyBy() a constant and still use timers

Upvotes: 0

David Anderson
David Anderson

Reputation: 43514

Flink's timers are only available within keyed process functions.

The standard answer to this question is to go ahead and key the stream, adding a field holding a random number to use as the key (if there isn't already a suitable way to implement a key selector).

If you can't live with the expense of a network shuffle, for event-time timers you could implement a custom operator that implements your logic in its processWatermark method.

And if you are looking for processing-time timers, you could roll your own.

Upvotes: 3

Related Questions