aaron-ai commented on a change in pull request #3987: URL: https://github.com/apache/rocketmq/pull/3987#discussion_r826599108
########## File path: apis/src/main/java/org/apache/rocketmq/apis/producer/ProducerBuilder.java ########## @@ -0,0 +1,92 @@ +/* + * 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 org.apache.rocketmq.apis.ClientConfiguration; +import org.apache.rocketmq.apis.retry.BackoffRetryPolicy; +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.NetworkConnectionException; +import org.apache.rocketmq.apis.exception.NetworkTimeoutException; +import org.apache.rocketmq.apis.exception.TopicDoesNotExistException; +import org.apache.rocketmq.apis.message.Message; + +/** + * Builder to config and start {@link Producer}. + */ +public interface ProducerBuilder { + /** + * Set the client configuration for producer. + * + * @param clientConfiguration client's configuration. + * @return the producer builder instance. + */ + ProducerBuilder setClientConfiguration(ClientConfiguration clientConfiguration); + + /** + * Declare topics ahead of message sending/preparation. + * + * <p>Even though the declaration is not essential, we <strong>highly recommend</strong> to declare the topics in + * advance, which could help to discover potential mistakes. + * + * @param topics topics to send/prepare. + * @return the producer builder instance. + */ + ProducerBuilder withTopics(String... topics); + + /** + * Set the threads count for {@link Producer#sendAsync(Message)}. + * + * @return the producer builder instance. + */ + ProducerBuilder setAsyncThreadCount(int count); + + /** + * Set the retry policy to send message. + * + * @param retryPolicy policy to re-send message when failure encountered. + * @return the producer builder instance. + */ + ProducerBuilder setRetryPolicy(BackoffRetryPolicy retryPolicy); Review comment: Yeah, this should be considered, we think that it is more strict if we use `BackoffRetryPolicy` here before we allow users to implement their `RetryPolicy`. -- 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]
