Interface KafkaPolicy
- All Superinterfaces:
BasePolicy
- All Known Subinterfaces:
KafkaSecurityPolicy
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:
ExecutionPhase.REQUEST:onRequest(KafkaExecutionContext)ExecutionPhase.RESPONSE:onResponse(KafkaExecutionContext)ExecutionPhase.MESSAGE_REQUEST:onMessageRequest(KafkaMessageExecutionContext). Flow of messages is derived from Kakfa ProduceRequest data.ExecutionPhase.MESSAGE_RESPONSE:onMessageResponse(KafkaMessageExecutionContext). Flow of messages is derived from Kakfa FetchResponse data.
- Author:
- Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com), GraviteeSource Team
-
Method Summary
Modifier and TypeMethodDescriptiondefault io.reactivex.rxjava3.core.CompletableDefine the actions to perform once api is deployed and the connection is established.default io.reactivex.rxjava3.core.CompletableDefine the actions to perform during theExecutionPhase.MESSAGE_REQUESTphase.default io.reactivex.rxjava3.core.CompletableDefine the actions to perform during theExecutionPhase.MESSAGE_RESPONSEphase.default io.reactivex.rxjava3.core.CompletableDefine the actions to perform during theExecutionPhase.REQUESTphase.default io.reactivex.rxjava3.core.CompletableDefine the actions to perform during theExecutionPhase.RESPONSEphase.Methods inherited from interface io.gravitee.gateway.reactive.api.policy.base.BasePolicy
id
-
Method Details
-
onInitialize
Define the actions to perform once api is deployed and the connection is established. TheonInitialize(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
Completablethat must complete when all the actions have been performed.
-
onRequest
Define the actions to perform during theExecutionPhase.REQUESTphase. TheonRequest(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
Completablethat must complete when all the actions have been performed.
-
onResponse
Define the actions to perform during theExecutionPhase.RESPONSEphase. TheonResponse(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
Completablethat must complete when all the actions have been performed.
-
onMessageRequest
Define the actions to perform during theExecutionPhase.MESSAGE_REQUESTphase. TheonMessageRequest(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
Completablethat must complete when all the actions have been performed.
-
onMessageResponse
Define the actions to perform during theExecutionPhase.MESSAGE_RESPONSEphase. TheonMessageResponse(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
Completablethat must complete when all the actions have been performed.
-