Anonymitaet commented on code in PR #17075:
URL: https://github.com/apache/pulsar/pull/17075#discussion_r945557867


##########
site2/docs/client-libraries-java.md:
##########
@@ -652,6 +652,43 @@ Producer<byte[]> producer = client.newProducer()
 By default, producer chunks the large message based on max message size 
(`maxMessageSize`) configured at broker (eg: 5MB). However, client can also 
configure max chunked size using producer configuration `chunkMaxMessageSize`.
 > **Note:** To enable chunking, you need to disable batching 
 > (`enableBatching`=`false`) concurrently.
 
+### Intercept messages
+
+`ProducerInterceptor`s intercept and possibly mutate messages received by the 
producer before they are published to the brokers.
+
+The interface has three main events:
+* `eligible` checks if the interceptor can be applied to the message.
+* `beforeSend` is triggered before the producer sends the message to the 
broker. You can modify messages within this event.
+* `onSendAcknowledgement` is triggered when the message is acknowledged by the 
broker or the sending failed.
+
+To intercept messages, you can add one or multiple `ProducerInterceptor`s when 
creating a `Producer` as follows.
+
+```java
+
+Producer<byte[]> producer = client.newProducer()
+        .topic(topic)
+        .intercept(new ProducerInterceptor {
+                       @Override
+                       boolean eligible(Message message) {
+                           return true;  // process all messages
+                       }
+
+                       @Override
+                       Message beforeSend(Producer producer, Message message) {
+                           // user-defined processing logic
+                       }
+
+                       @Override
+                       void onSendAcknowledgement(Producer producer, Message 
message, MessageId msgId, Throwable exception) {
+                           // user-defined processing logic
+                       }
+        })
+        .create();
+
+```
+
+> **Note:** If you are using multiple interceptors, they apply in the order 
they are passed to the `intercept` method.

Review Comment:
   ```suggestion
   :::note
   
   If you are using multiple interceptors, they apply in the order they are 
passed to the `intercept` method.
   
   :::
   ```
   
   Please follow the syntax here: 
https://docs.google.com/document/d/12De2btkDHQVaqUlHjTqERmroMLKGhHdiC7rEttFTyqc/edit#bookmark=id.jis8plesauvo



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to