Reputation: 75
I was wondering if ProcessorContext.schedule is thread-safe so that I can spawn new thread to execute the Punctuator callback?
Also, if a consumer consumes just 1 partition but we set num.stream.threads=2
. Does this automatically spawn a new thread for the scheduler?
After trying it a bit I found the answer may be "no". Then what's the recommended the way to make spawning new thread for scheduler thread-safe?
Upvotes: 1
Views: 911
Reputation: 62350
Registering a punctuation will not spawn a new thread. The number of used threads in determined by num.stream.threads
configuration only. Hence, if you register a punctuation, it's executed on the same thread as the topology and thus it is thread safe.
If you configure more threads than available input topic partitions, some threads would not get any work assigned, and thus, they would not execute any punctuations.
Upvotes: 2