How can I get the key in the onTimer function of a...
# troubleshooting
a
How can I get the key in the onTimer function of a CoProcessFunction?
o
the onTimer method contains the parameter OnTimerContext you can simply call ctx.getCurrentKey() from there. hope it helps
a
Thanks, I tried that, but unfortunately I get an error -
Copy code
The method getCurrentKey() is undefined for the type CoProcessFunction
o
ok I can give you some code snippets, see how they can correlate. We use kotlin, but should be the same: This is our class:
Copy code
class ClusterProcessFunction :
    KeyedCoProcessFunction<String, AccountAndActivityTagged, UserActivity, CustomerClusterChangedEvent>() {
and this our onTimer method implementation:
Copy code
override fun onTimer(timestamp: Long, ctx: OnTimerContext, out: Collector<CustomerClusterChangedEvent>) {
   ctx.currentKey
}
hope makes some sense?
I guess the keyword here is KeyedCoProcessFunction and not CoProcessFunction