codelipenghui commented on a change in pull request #14613:
URL: https://github.com/apache/pulsar/pull/14613#discussion_r826521139



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptor.java
##########
@@ -123,6 +123,23 @@ default void messageAcked(ServerCnx cnx, Consumer consumer,
                               CommandAck ackCmd) {
     }
 
+    /**
+     * Intercept when a transaction begins.
+     *
+     * @param tcId Transaction Coordinator Id
+     * @param txnID Transaction ID
+     */
+    default void beginTxn(long tcId, String txnID) {

Review comment:
       And from the implementation, I think it should be `txnOpened` and 
`txnEnded`?

##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -2172,6 +2172,9 @@ protected void handleNewTxn(CommandNewTxn command) {
                     }
                     ctx.writeAndFlush(Commands.newTxnResponse(requestId, 
txnID.getLeastSigBits(),
                             txnID.getMostSigBits()));
+                    if (getBrokerService().getInterceptor() != null) {
+                        
getBrokerService().getInterceptor().beginTxn(command.getTcId(), 
txnID.toString());
+                    }

Review comment:
       It's better to move to `PulsarCommandSender` so that we can have a 
unified management of sent commands and interception

##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptor.java
##########
@@ -123,6 +123,23 @@ default void messageAcked(ServerCnx cnx, Consumer consumer,
                               CommandAck ackCmd) {
     }
 
+    /**
+     * Intercept when a transaction begins.
+     *
+     * @param tcId Transaction Coordinator Id
+     * @param txnID Transaction ID
+     */
+    default void beginTxn(long tcId, String txnID) {

Review comment:
       It's better to use newTxn to keep consistent with the command.




-- 
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: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to