Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancelling Scheduled Punctuator after a single iteration #114

Closed
viktorjucas opened this issue May 9, 2018 · 7 comments
Closed

Cancelling Scheduled Punctuator after a single iteration #114

viktorjucas opened this issue May 9, 2018 · 7 comments

Comments

@viktorjucas
Copy link

Is there an easy way to cancel a scheduled punctuator after the first time it runs?

@guozhangwang
Copy link
Contributor

@viktorjucas Yes, note that ProcessorContex#schedule returns a Cancellable event. You can cancel it even within the punctuate call. For example:

Cancellable scheduled;
scheduled = context.schedule(... timestamp -> scheduled.cancel);

@viktorjucas
Copy link
Author

I have tried that and it doesn't seem to be cancelling.

public class Transformer implements Transformer<> {
    private ProcessorContext context;
    private Cancellable scheduled;

    @Override
    public void init(PorcessorContext processContext) {
        this.context = processorContext;
        scheduled = context.schedule(TimeUnit.SECONDS.toMillis(5), PunctuationType.WALL_CLOCK_TIME,
                                     this::punctuateCancel);
    }

    private void punctuateCancel(long timestamp) {
        scheduled.cancel();
    }
}

@guozhangwang
Copy link
Contributor

Which version are you using? Note that this functionality is fixed in 1.1.1: https://issues.apache.org/jira/browse/KAFKA-6748

@viktorjucas
Copy link
Author

That's the reason. I was using 1.1.0.

@viktorjucas
Copy link
Author

Closed prematurely.

Is v1.1.1 available through Maven already?

@guozhangwang
Copy link
Contributor

No it is not released out yet: https://mvnrepository.com/artifact/org.apache.kafka/kafka-streams

If you have to cancel the even within the punctuate call, you can consider backporting that fix into your source code build.

@mjsax
Copy link
Member

mjsax commented Jul 20, 2018

@viktorjucas Kafka 1.1.1 is released now. Can you try it out and verify the fix so we can close this issue?

@mjsax mjsax closed this as completed Aug 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants