You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Matthias J. Sax (Jira)" <ji...@apache.org> on 2024/12/17 23:26:00 UTC

[jira] [Resolved] (KAFKA-4713) Processors cannot call public methods on ProcessorContext from the init method

     [ https://issues.apache.org/jira/browse/KAFKA-4713?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matthias J. Sax resolved KAFKA-4713.
------------------------------------
    Resolution: Won't Fix

In AK 2.7, we introduces the new `api.Processor` with new `api.ProcessorContext` which partially address this issue.

The old `Processor` is removed with 4.0.0 release. Thus, closing this ticket.

> Processors cannot call public methods on ProcessorContext from the init method
> ------------------------------------------------------------------------------
>
>                 Key: KAFKA-4713
>                 URL: https://issues.apache.org/jira/browse/KAFKA-4713
>             Project: Kafka
>          Issue Type: Improvement
>          Components: streams
>    Affects Versions: 0.10.0.1
>            Reporter: Bruno Felaco
>            Priority: Major
>
> Streams passes the ProcessorContext to the init method of a Processor on startup when a topic/partition is assigned. This is the only means that a Processor has to obtain a reference to the ProcessorContext, which is required if the implementation needs to be aware of the particular topic/partition that is being processed. However, from within the init() method, the only thing the implementation is allowed to do with the ProcessorContext is schedule periodic tasks and create/access any state stores.  It is not allowed to get the topic, partition, or current offset. This severely limits what an implementation can do in init. An implementation may need to check with or notify another component or system that it has been assigned a particular topic/partition. As far as I can see, there is no other mechanism in Streams to allow an implementation to react to the assignment of topic/partition and perform any such initialization, since Streams explicitly controls the ConsumerRebalanceListener. The implementation would have to wait for the receipt of the first record to get this information which is too late for certain use cases.
> I propose that the following methods should be usable from the init method:
> topic()
> partition()
> and also, but not as critical:
> offset()
> timestamp()
> Alternatively, streams could allow an implementation to register a separate listener that would be invoked from the global ConsumerRebalanceListener  when a topic/partition is assigned.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)