zhouxinyu commented on a change in pull request #3987:
URL: https://github.com/apache/rocketmq/pull/3987#discussion_r826829945



##########
File path: apis/src/main/java/org/apache/rocketmq/apis/producer/Transaction.java
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.apis.producer;
+
+/**
+ * An entity to describe an independent transaction, which follows
+ * <a href="https://en.wikipedia.org/wiki/Two-phase_commit_protocol";>two-phase 
commit protocol</a>.
+ *
+ * <p>once {@link Transaction#commit()} or {@link Transaction#rollback()} is 
invoked, subsequent commit or rollback in
+ * {@link Transaction} is ignored by client.
+ *
+ * <p>Neither of {@link Transaction#commit()} and {@link 
Transaction#rollback()} ensures the success on account of
+ * network timeout or other issues, that's why it does not make any sense to 
execute {@link Transaction#commit()} or
+ * {@link Transaction#rollback()} after is has been executed once already. The 
suspended transaction will be
+ * solved by {@link TransactionChecker}.
+ */
+public interface Transaction {
+    /**
+     * Try to commit the transaction, which would expose the message before 
the transaction is closed.
+     *
+     * <p>We don't ensure this operation is successful even though no 
exception is thrown after invocation,
+     * <strong>actually we omit the exception on purpose because {@link 
TransactionChecker} is the unique right way
+     * to solve the suspended transaction rather than commit or roll-back 
repeatedly.</strong>
+     */
+    void commit();

Review comment:
       `TransactionChecker` is less real-time, which may result in high latency 
when the commit failed.




-- 
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