Class BrokerInterceptors
java.lang.Object
org.apache.pulsar.broker.intercept.BrokerInterceptors
- All Implemented Interfaces:
AutoCloseable,BrokerInterceptor
A collection of broker interceptor.
-
Constructor Summary
ConstructorsConstructorDescriptionBrokerInterceptors(Map<String, BrokerInterceptorWithClassLoader> interceptors) -
Method Summary
Modifier and TypeMethodDescriptionvoidbeforeSendMessage(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.voidIntercept after a consumer is created.voidinitialize(PulsarService pulsarService) Initialize the broker interceptor.static BrokerInterceptorload(org.apache.pulsar.broker.ServiceConfiguration conf) Load the broker event interceptor for the given interceptor list.voidmessageAcked(ServerCnx cnx, Consumer consumer, org.apache.pulsar.common.api.proto.CommandAck ackCmd) Intercept after a message ack is processed.voidmessageDispatched(ServerCnx cnx, Consumer consumer, long ledgerId, long entryId, io.netty.buffer.ByteBuf headersAndPayload) Intercept after a message is dispatched to consumer.voidmessageProduced(ServerCnx cnx, Producer producer, long startTimeNs, long ledgerId, long entryId, Topic.PublishContext publishContext) Intercept after a message is produced.voidCalled by the broker while connection closed.voidCalled by the broker when a new connection is created.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.voidCalled by the broker when a new connection is created.voidIntercept when a transaction ends.voidIntercept when a transaction begins.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.pulsar.broker.intercept.BrokerInterceptor
onFilter
-
Constructor Details
-
BrokerInterceptors
-
-
Method Details
-
load
public static BrokerInterceptor load(org.apache.pulsar.broker.ServiceConfiguration conf) throws IOException Load the broker event interceptor for the given interceptor list.- Parameters:
conf- the pulsar broker service configuration- Returns:
- the collection of broker event interceptor
- Throws:
IOException
-
beforeSendMessage
public void beforeSendMessage(Subscription subscription, org.apache.bookkeeper.mledger.Entry entry, long[] ackSet, org.apache.pulsar.common.api.proto.MessageMetadata msgMetadata) Description copied from interface:BrokerInterceptorIntercept messages before sending them to the consumers.- Specified by:
beforeSendMessagein interfaceBrokerInterceptor- 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.
-
consumerCreated
Description copied from interface:BrokerInterceptorIntercept after a consumer is created.- Specified by:
consumerCreatedin interfaceBrokerInterceptor- Parameters:
cnx- client Connectionconsumer- Consumer objectmetadata- A map of metadata
-
producerCreated
Description copied from interface:BrokerInterceptorCalled by the broker when a new connection is created.- Specified by:
producerCreatedin interfaceBrokerInterceptor
-
messageProduced
public void messageProduced(ServerCnx cnx, Producer producer, long startTimeNs, long ledgerId, long entryId, Topic.PublishContext publishContext) Description copied from interface:BrokerInterceptorIntercept after a message is produced.- Specified by:
messageProducedin interfaceBrokerInterceptor- Parameters:
cnx- client Connectionproducer- Producer objectpublishContext- Publish Context
-
messageDispatched
public void messageDispatched(ServerCnx cnx, Consumer consumer, long ledgerId, long entryId, io.netty.buffer.ByteBuf headersAndPayload) Description copied from interface:BrokerInterceptorIntercept after a message is dispatched to consumer.- Specified by:
messageDispatchedin interfaceBrokerInterceptor- Parameters:
cnx- client Connectionconsumer- Consumer objectledgerId- Ledger IDentryId- Entry IDheadersAndPayload- Data
-
messageAcked
public void messageAcked(ServerCnx cnx, Consumer consumer, org.apache.pulsar.common.api.proto.CommandAck ackCmd) Description copied from interface:BrokerInterceptorIntercept after a message ack is processed.- Specified by:
messageAckedin interfaceBrokerInterceptor- Parameters:
cnx- client ConnectionackCmd- Command object
-
txnOpened
Description copied from interface:BrokerInterceptorIntercept when a transaction begins.- Specified by:
txnOpenedin interfaceBrokerInterceptor- Parameters:
tcId- Transaction Coordinator IdtxnID- Transaction ID
-
txnEnded
Description copied from interface:BrokerInterceptorIntercept when a transaction ends.- Specified by:
txnEndedin interfaceBrokerInterceptor- Parameters:
txnID- Transaction IDtxnAction- Transaction Action
-
onConnectionCreated
Description copied from interface:BrokerInterceptorCalled by the broker when a new connection is created.- Specified by:
onConnectionCreatedin interfaceBrokerInterceptor
-
onPulsarCommand
public void onPulsarCommand(org.apache.pulsar.common.api.proto.BaseCommand command, ServerCnx cnx) throws org.apache.pulsar.common.intercept.InterceptException Description copied from interface:BrokerInterceptorCalled by the broker while new command incoming.- Specified by:
onPulsarCommandin interfaceBrokerInterceptor- Throws:
org.apache.pulsar.common.intercept.InterceptException
-
onConnectionClosed
Description copied from interface:BrokerInterceptorCalled by the broker while connection closed.- Specified by:
onConnectionClosedin interfaceBrokerInterceptor
-
onWebserviceRequest
public void onWebserviceRequest(javax.servlet.ServletRequest request) throws IOException, javax.servlet.ServletException, org.apache.pulsar.common.intercept.InterceptException Description copied from interface:BrokerInterceptorCalled by the web service while new request incoming.- Specified by:
onWebserviceRequestin interfaceBrokerInterceptor- Throws:
IOExceptionjavax.servlet.ServletExceptionorg.apache.pulsar.common.intercept.InterceptException
-
onWebserviceResponse
public void onWebserviceResponse(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response) throws IOException, javax.servlet.ServletException Description copied from interface:BrokerInterceptorIntercept the webservice response before send to client.- Specified by:
onWebserviceResponsein interfaceBrokerInterceptor- Throws:
IOExceptionjavax.servlet.ServletException
-
initialize
Description copied from interface:BrokerInterceptorInitialize the broker interceptor.- Specified by:
initializein interfaceBrokerInterceptor- Throws:
Exception- when fail to initialize the broker interceptor.
-
close
public void close()Description copied from interface:BrokerInterceptorClose this broker interceptor.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceBrokerInterceptor
-