@Documented @Retention(value=RUNTIME) @Target(value={FIELD,PARAMETER}) @Experimental(value=TIMERS) public static @interface DoFn.TimerId
To declare a timer, create a field of type TimerSpec
annotated with a DoFn.TimerId
. To use the cell during processing, add a parameter of the type Timer
to your
@ProcessElement
or @OnTimer
method, and annotate it with
DoFn.TimerId
. See the following code for an example:
new DoFn<KV<Key, Foo>, Baz>() {
@TimerId("my-timer-id")
private final TimerSpec myTimer = TimerSpecs.timerForDomain(TimeDomain.EVENT_TIME);
@ProcessElement
public void processElement(
ProcessContext c,
@TimerId("my-timer-id") Timer myTimer) {
myTimer.offset(Duration.standardSeconds(...)).setRelative();
}
@OnTimer("my-timer-id")
public void onMyTimer() {
...
}
}
Timers are subject to the following validity conditions:
@OnTimer
.
Modifier and Type | Required Element and Description |
---|---|
java.lang.String |
value
The timer ID.
|