Interface RequestFilter

All Superinterfaces:
Filter

public interface RequestFilter extends Filter

A Filter that handles all request types, for example to modify the request headers.

When a Filter implements RequestFilter:

  • it must not also implement any of the message-specific *RequestFilter interfaces like ApiVersionsRequestFilter.
  • it may also implement either ResponseFilter or any of the message-specific *ResponseFilter interfaces, but not both.
  • Method Summary

    Modifier and Type
    Method
    Description
    onRequest(org.apache.kafka.common.protocol.ApiKeys apiKey, short apiVersion, org.apache.kafka.common.message.RequestHeaderData header, org.apache.kafka.common.protocol.ApiMessage request, FilterContext context)
    Handle the given header and request pair, returning the header and request pair to be passed to the next filter using the RequestFilterResult.
    onRequest(org.apache.kafka.common.protocol.ApiKeys apiKey, org.apache.kafka.common.message.RequestHeaderData header, org.apache.kafka.common.protocol.ApiMessage request, FilterContext context)
    Deprecated, for removal: This API element is subject to removal in a future version.
    default boolean
    shouldHandleRequest(org.apache.kafka.common.protocol.ApiKeys apiKey, short apiVersion)
    Does this filter implementation want to handle a request.
  • Method Details

    • shouldHandleRequest

      default boolean shouldHandleRequest(org.apache.kafka.common.protocol.ApiKeys apiKey, short apiVersion)
      Does this filter implementation want to handle a request. If so, the onRequest(ApiKeys, short, RequestHeaderData, ApiMessage, FilterContext) method will be eligible to be called with the deserialized request data (if the message reaches this filter in the filter chain).
      Parameters:
      apiKey - the api key of the message
      apiVersion - the api version of the message
      Returns:
      true if this filter wants to handle the request
    • onRequest

      @Deprecated(forRemoval=true, since="0.19.0") default CompletionStage<RequestFilterResult> onRequest(org.apache.kafka.common.protocol.ApiKeys apiKey, org.apache.kafka.common.message.RequestHeaderData header, org.apache.kafka.common.protocol.ApiMessage request, FilterContext context)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Handle the given header and request pair, returning the header and request pair to be passed to the next filter using the RequestFilterResult.
      The implementation may modify the given header and request in-place, or instantiate a new instances.
      Parameters:
      apiKey - key of the request
      header - header of the request
      request - body of the request
      context - context containing methods to continue the filter chain and other contextual data
      Returns:
      a non-null CompletionStage that, when complete, will yield a RequestFilterResult containing the request to be forwarded.
      See Also:
    • onRequest

      default CompletionStage<RequestFilterResult> onRequest(org.apache.kafka.common.protocol.ApiKeys apiKey, short apiVersion, org.apache.kafka.common.message.RequestHeaderData header, org.apache.kafka.common.protocol.ApiMessage request, FilterContext context)
      Handle the given header and request pair, returning the header and request pair to be passed to the next filter using the RequestFilterResult.
      The implementation may modify the given header and request in-place, or instantiate a new instances.
      Parameters:
      apiKey - key of the request
      apiVersion - api version of the request
      header - header of the request
      request - body of the request
      context - context containing methods to continue the filter chain and other contextual data
      Returns:
      a non-null CompletionStage that, when complete, will yield a RequestFilterResult containing the request to be forwarded.
      See Also: