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



##########
File path: apis/src/main/java/org/apache/rocketmq/apis/producer/Producer.java
##########
@@ -0,0 +1,132 @@
+/*
+ * 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;
+
+import com.google.common.util.concurrent.Service;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.io.Closeable;
+import java.util.Collection;
+import org.apache.rocketmq.apis.exception.AuthenticationException;
+import org.apache.rocketmq.apis.exception.AuthorisationException;
+import org.apache.rocketmq.apis.exception.ClientException;
+import org.apache.rocketmq.apis.exception.MessageTypeDoesNotMatchException;
+import org.apache.rocketmq.apis.exception.PersistenceException;
+import org.apache.rocketmq.apis.exception.ProducerClosedAlreadyException;
+import org.apache.rocketmq.apis.exception.NetworkConnectionException;
+import org.apache.rocketmq.apis.exception.NetworkTimeoutException;
+import org.apache.rocketmq.apis.exception.TopicDoesNotExistException;
+import org.apache.rocketmq.apis.exception.TransactionCheckerNotSetException;
+import org.apache.rocketmq.apis.message.Message;
+import org.apache.rocketmq.apis.message.MessageId;
+
+/**
+ * Producer is a thread-safe rocketmq client which is used to publish messages.
+ *
+ * <p>On account of network timeout or other reasons, rocketmq producer only 
promised the at-least-once semantics.
+ * For producer, at-least-once semantics means potentially attempts are made 
at sending it, messages may be
+ * duplicated but not lost.
+ */
+public interface Producer extends Closeable {
+    /**
+     * Sends a message synchronously.
+     *
+     * <p>This method does not return until it gets the definitive result.
+     *
+     * @param message message to send.
+     * @return the message id assigned to the appointed message.
+     * @throws TopicDoesNotExistException       if the topic of message does 
not exist.
+     * @throws AuthorisationException           if no permission to send 
message.
+     * @throws AuthenticationException          if identification could not be 
recognized by server.
+     * @throws ProducerClosedAlreadyException   if producer is closed already.
+     * @throws MessageTypeDoesNotMatchException if message type does not match 
with the topic.
+     * @throws NetworkTimeoutException          if encountered network timeout 
to communicate with server.
+     * @throws NetworkConnectionException       if there is a network 
connection problem.
+     * @throws PersistenceException             if encountered persistence 
failure from server.
+     */
+    MessageId send(Message message) throws ClientException;
+
+    /**
+     * Sends a transactional message synchronously.
+     *
+     * @param message     message to send.
+     * @param transaction transaction to bind.
+     * @return the message id assigned to the appointed message.
+     * @throws TopicDoesNotExistException        if the topic of message does 
not exist.
+     * @throws AuthorisationException            if no permission to send 
message.
+     * @throws AuthenticationException           if identification could not 
be recognized by server.
+     * @throws ProducerClosedAlreadyException    if producer is closed already.
+     * @throws MessageTypeDoesNotMatchException  if message type does not 
match with the topic.
+     * @throws NetworkTimeoutException           if encountered network 
timeout to communicate with server.
+     * @throws NetworkConnectionException        if there is a network 
connection problem.
+     * @throws PersistenceException              if encountered persistence 
failure from server.
+     * @throws TransactionCheckerNotSetException if {@link TransactionChecker} 
is not set.
+     */
+    MessageId send(Message message, Transaction transaction) throws 
ClientException;

Review comment:
       How to send more than one message using such API?
   MessageId send(Message message, Transaction transaction)
   
   
   The old API  for the transaction is not naturally two-phase based. It's 
better to polish it in the new API.
   But currently, the new API is just like the old
   




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