Interface KafkaPolicy

All Superinterfaces:
BasePolicy
All Known Subinterfaces:
KafkaSecurityPolicy

public interface KafkaPolicy extends BasePolicy
A KafkaPolicy allows to define the actions to apply during the different Kafka requests and responses. A policy can override the default behavior (which is, doing nothing at all) to execute during the Kafka request or response phase or on each message when the policy is able to work at message level. In the case of records from ProduceRequest and FetchResponse. The implemented methods will be called depending on the execution phase:
Author:
Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com), GraviteeSource Team
  • Method Details

    • onInitialize

      default io.reactivex.rxjava3.core.Completable onInitialize(KafkaConnectionContext ctx)
      Define the actions to perform once api is deployed and the connection is established. The onInitialize(KafkaConnectionContext) method will be called once before any policy chain construction.
      Parameters:
      ctx - the current connection context allowing to access the connection attributes & topicIdentityRegistry.
      Returns:
      a Completable that must complete when all the actions have been performed.
    • onRequest

      default io.reactivex.rxjava3.core.Completable onRequest(KafkaExecutionContext ctx)
      Define the actions to perform during the ExecutionPhase.REQUEST phase. The onRequest(KafkaExecutionContext) method will be called during the policy chain construction. Once built, the subscription occurs and the execution is triggered. It is important that nothing must be executed before the subscription occurs as it could lead to important side effects.
      Parameters:
      ctx - the current request execution context allowing to access the request, response and attributes.
      Returns:
      a Completable that must complete when all the actions have been performed.
    • onResponse

      default io.reactivex.rxjava3.core.Completable onResponse(KafkaExecutionContext ctx)
      Define the actions to perform during the ExecutionPhase.RESPONSE phase. The onResponse(KafkaExecutionContext) method will be called during the policy chain construction. Once built, the subscription occurs and the execution is triggered. It is important that nothing must be executed before the subscription occurs as it could lead to important side effects.
      Parameters:
      ctx - the current request execution context allowing to access the request, response and attributes.
      Returns:
      a Completable that must complete when all the actions have been performed.
    • onMessageRequest

      default io.reactivex.rxjava3.core.Completable onMessageRequest(KafkaMessageExecutionContext ctx)
      Define the actions to perform during the ExecutionPhase.MESSAGE_REQUEST phase. The onMessageRequest(KafkaMessageExecutionContext) method will be called during the policy chain construction. Once built, the subscription occurs and the execution is triggered. It is important that nothing must be executed before the subscription occurs as it could lead to important side effects.
      Parameters:
      ctx - the current request execution context allowing to access the request, response and attributes.
      Returns:
      a Completable that must complete when all the actions have been performed.
    • onMessageResponse

      default io.reactivex.rxjava3.core.Completable onMessageResponse(KafkaMessageExecutionContext ctx)
      Define the actions to perform during the ExecutionPhase.MESSAGE_RESPONSE phase. The onMessageResponse(KafkaMessageExecutionContext) method will be called during the policy chain construction. Once built, the subscription occurs and the execution is triggered. It is important that nothing must be executed before the subscription occurs as it could lead to important side effects.
      Parameters:
      ctx - the current request execution context allowing to access the request, response and attributes.
      Returns:
      a Completable that must complete when all the actions have been performed.