[ 
https://issues.apache.org/jira/browse/ROCKETMQ-26?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15790886#comment-15790886
 ] 

ASF GitHub Bot commented on ROCKETMQ-26:
----------------------------------------

Github user thisisbaozi commented on a diff in the pull request:

    https://github.com/apache/incubator-rocketmq/pull/26#discussion_r94282172
  
    --- Diff: 
client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultSendPromise.java
 ---
    @@ -0,0 +1,302 @@
    +/*
    + * 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.client.impl.producer;
    +
    +import java.util.concurrent.CountDownLatch;
    +import java.util.concurrent.ExecutionException;
    +import java.util.concurrent.Executor;
    +import java.util.concurrent.ExecutorService;
    +import java.util.concurrent.TimeUnit;
    +import java.util.concurrent.TimeoutException;
    +import org.apache.rocketmq.client.log.ClientLogger;
    +import org.apache.rocketmq.client.producer.SendCallback;
    +import org.apache.rocketmq.client.producer.SendFuture;
    +import org.apache.rocketmq.client.producer.SendResult;
    +import org.slf4j.Logger;
    +
    +import java.util.ArrayList;
    +import java.util.List;
    +
    +/**
    + * Created by stone
    + */
    --- End diff --
    
    Removed


> add a new way to send message in async
> --------------------------------------
>
>                 Key: ROCKETMQ-26
>                 URL: https://issues.apache.org/jira/browse/ROCKETMQ-26
>             Project: Apache RocketMQ
>          Issue Type: New Feature
>            Reporter: stone
>            Assignee: vongosling
>
> an new way to send message in async way, it looks like:
> MQProducer producer = ...;
> ExecutorService sharedExecutorService = ...
> SendFuture future = producer.send(msg, sharedExecutorService, timeout);
> future.addCallback(new SendCallback() {
>             @Override
>             public void onSuccess(SendResult sendResult) {
>                   // do sth 
>             }
>             @Override
>             public void onException(Throwable e) {
>                    // do sth
>             }
> })
> There are three advantages for this way:
> 0. Executes the callback logic in exclusive thread pool
> 1. Multiple callbacks are allowed
> 2. Gets the result of sending in synchronous API(get/get(time, unit))



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to