Interface BrokerInterceptor
-
- All Superinterfaces:
java.lang.AutoCloseable
- All Known Implementing Classes:
BrokerInterceptor.BrokerInterceptorDisabled,BrokerInterceptors,BrokerInterceptorWithClassLoader
@LimitedPrivate @Evolving public interface BrokerInterceptor extends java.lang.AutoCloseableA plugin interface that allows you to intercept the client requests to the Pulsar brokers.BrokerInterceptor callbacks may be called from multiple threads. Interceptor implementation must ensure thread-safety, if needed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classBrokerInterceptor.BrokerInterceptorDisabledBroker interceptor disabled implementation.
-
Field Summary
Fields Modifier and Type Field Description static BrokerInterceptorDISABLED
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidbeforeSendMessage(Subscription subscription, org.apache.bookkeeper.mledger.Entry entry, long[] ackSet, org.apache.pulsar.common.api.proto.MessageMetadata msgMetadata)Intercept messages before sending them to the consumers.voidclose()Close this broker interceptor.default voidconsumerCreated(ServerCnx cnx, Consumer consumer, java.util.Map<java.lang.String,java.lang.String> metadata)Intercept after a consumer is created.voidinitialize(PulsarService pulsarService)Initialize the broker interceptor.default voidmessageAcked(ServerCnx cnx, Consumer consumer, org.apache.pulsar.common.api.proto.CommandAck ackCmd)Intercept after a message ack is processed.default voidmessageDispatched(ServerCnx cnx, Consumer consumer, long ledgerId, long entryId, io.netty.buffer.ByteBuf headersAndPayload)Intercept after a message is dispatched to consumer.default voidmessageProduced(ServerCnx cnx, Producer producer, long startTimeNs, long ledgerId, long entryId, Topic.PublishContext publishContext)Intercept after a message is produced.voidonConnectionClosed(ServerCnx cnx)Called by the broker while connection closed.default voidonConnectionCreated(ServerCnx cnx)Called by the broker when a new connection is created.default voidonFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)The interception of web processing, as same as `Filter.onFilter`.voidonPulsarCommand(org.apache.pulsar.common.api.proto.BaseCommand command, ServerCnx cnx)Called by the broker while new command incoming.voidonWebserviceRequest(javax.servlet.ServletRequest request)Called by the web service while new request incoming.voidonWebserviceResponse(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)Intercept the webservice response before send to client.default voidproducerCreated(ServerCnx cnx, Producer producer, java.util.Map<java.lang.String,java.lang.String> metadata)Called by the broker when a new connection is created.
-
-
-
Field Detail
-
DISABLED
static final BrokerInterceptor DISABLED
-
-
Method Detail
-
beforeSendMessage
default void beforeSendMessage(Subscription subscription, org.apache.bookkeeper.mledger.Entry entry, long[] ackSet, org.apache.pulsar.common.api.proto.MessageMetadata msgMetadata)
Intercept messages before sending them to the consumers.- Parameters:
subscription- pulsar subscriptionentry- entryackSet- entry ack bitset. it is either null or an array of long-based bitsets.msgMetadata- message metadata. The message metadata will be recycled after this call.
-
onConnectionCreated
default void onConnectionCreated(ServerCnx cnx)
Called by the broker when a new connection is created.
-
producerCreated
default void producerCreated(ServerCnx cnx, Producer producer, java.util.Map<java.lang.String,java.lang.String> metadata)
Called by the broker when a new connection is created.
-
consumerCreated
default void consumerCreated(ServerCnx cnx, Consumer consumer, java.util.Map<java.lang.String,java.lang.String> metadata)
Intercept after a consumer is created.- Parameters:
cnx- client Connectionconsumer- Consumer objectmetadata- A map of metdata
-
messageProduced
default void messageProduced(ServerCnx cnx, Producer producer, long startTimeNs, long ledgerId, long entryId, Topic.PublishContext publishContext)
Intercept after a message is produced.- Parameters:
cnx- client Connectionproducer- Producer objectpublishContext- Publish Context
-
messageDispatched
default void messageDispatched(ServerCnx cnx, Consumer consumer, long ledgerId, long entryId, io.netty.buffer.ByteBuf headersAndPayload)
Intercept after a message is dispatched to consumer.- Parameters:
cnx- client Connectionconsumer- Consumer objectledgerId- Ledger IDentryId- Entry IDheadersAndPayload- Data
-
messageAcked
default void messageAcked(ServerCnx cnx, Consumer consumer, org.apache.pulsar.common.api.proto.CommandAck ackCmd)
Intercept after a message ack is processed.- Parameters:
cnx- client ConnectionackCmd- Command object
-
onPulsarCommand
void onPulsarCommand(org.apache.pulsar.common.api.proto.BaseCommand command, ServerCnx cnx) throws org.apache.pulsar.common.intercept.InterceptExceptionCalled by the broker while new command incoming.- Throws:
org.apache.pulsar.common.intercept.InterceptException
-
onConnectionClosed
void onConnectionClosed(ServerCnx cnx)
Called by the broker while connection closed.
-
onWebserviceRequest
void onWebserviceRequest(javax.servlet.ServletRequest request) throws java.io.IOException, javax.servlet.ServletException, org.apache.pulsar.common.intercept.InterceptExceptionCalled by the web service while new request incoming.- Throws:
java.io.IOExceptionjavax.servlet.ServletExceptionorg.apache.pulsar.common.intercept.InterceptException
-
onWebserviceResponse
void onWebserviceResponse(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response) throws java.io.IOException, javax.servlet.ServletExceptionIntercept the webservice response before send to client.- Throws:
java.io.IOExceptionjavax.servlet.ServletException
-
onFilter
default void onFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) throws java.io.IOException, javax.servlet.ServletExceptionThe interception of web processing, as same as `Filter.onFilter`. So In this method, we must call `chain.doFilter` to continue the chain.- Throws:
java.io.IOExceptionjavax.servlet.ServletException
-
initialize
void initialize(PulsarService pulsarService) throws java.lang.Exception
Initialize the broker interceptor.- Throws:
java.lang.Exception- when fail to initialize the broker interceptor.
-
close
void close()
Close this broker interceptor.- Specified by:
closein interfacejava.lang.AutoCloseable
-
-