/**
 * Copyright (C) 2010-2013 Alibaba Group Holding Limited
 *
 * Licensed 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 com.alibaba.rocketmq.example.quickstart;

import com.alibaba.rocketmq.client.exception.MQClientException;
import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
import com.alibaba.rocketmq.client.producer.SendCallback;
import com.alibaba.rocketmq.client.producer.SendResult;
import com.alibaba.rocketmq.client.producer.selector.Region;
import com.alibaba.rocketmq.client.producer.selector.SelectMessageQueueByRegion;
import com.alibaba.rocketmq.common.message.Message;
import com.alibaba.rocketmq.common.protocol.ResponseCode;


/**
 * ExampleCacheableProducer，发送消息
 */
public class Producer {
    public static void main(String[] args) throws MQClientException, InterruptedException {
        DefaultMQProducer producer = new DefaultMQProducer("PG_QuickStart");
        producer.setNamesrvAddr("172.30.30.125:9876");
        producer.setSendMsgTimeout(10000);
        producer.setSendLatencyFaultEnable(true);
        producer.start();

        for (int i = 0; i < 1024; i++) {
            try {
                Message msg = new Message("T_QuickStart",// topic
                        "TagA",// tag
                        ("Hello RocketMQ " + i).getBytes()// body
                );
//                msg.setUnitTestCode(ResponseCode.FLUSH_DISK_TIMEOUT);
//                SendResult sendResult = producer.send(msg);
//                System.out.println(sendResult);
                producer.send(msg, new SelectMessageQueueByRegion(Region.ANY), null, new SendCallback() {
                    @Override
                    public void onSuccess(SendResult sendResult) {
                        System.out.println(sendResult);
                    }

                    @Override
                    public void onException(Throwable e) {
                        e.printStackTrace();
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
                Thread.sleep(1000);
            }
        }
        producer.shutdown();
    }
}

@@ -845,214 +845,14 @@
 Send
-Callback;%0Aimport com.alibaba.rocketmq.client.producer.SendResult;%0Aimport com.alibaba.rocketmq.client.producer.selector.Region;%0Aimport com.alibaba.rocketmq.client.producer.selector.SelectMessageQueueByRegion
+Result
 ;%0Aim
@@ -905,64 +905,32 @@
 ge;%0A
+%0A
 import 
-com.alibaba.rocketmq.common.protocol.ResponseCode
+java.util.Arrays
 ;%0A%0A%0A
@@ -1167,63 +1167,8 @@
 %22);%0A
-        producer.setNamesrvAddr(%22172.30.30.125:9876%22);%0A
     
@@ -1282,16 +1282,91 @@
 tart();%0A
+        byte%5B%5D data = new byte%5B1024%5D;%0A        Arrays.fill(data, (byte)'x');
 %0A       
@@ -1386,20 +1386,33 @@
  0; i %3C 
-1024
+Integer.MAX_VALUE
 ; i++) %7B
@@ -1562,143 +1562,32 @@
     
-(%22Hello RocketMQ %22 + i).getBytes()// body%0A                );%0A//                msg.setUnitTestCode(ResponseCode.FLUSH_DISK_TIMEOUT);%0A//
+data%0A                );%0A
     
@@ -1642,18 +1642,16 @@
 d(msg);%0A
-//
         
@@ -1682,32 +1682,34 @@
 ln(sendResult);%0A
+//
                 
@@ -1794,24 +1794,26 @@
 allback() %7B%0A
+//
             
@@ -1822,32 +1822,34 @@
       @Override%0A
+//
                 
@@ -1895,24 +1895,26 @@
 ndResult) %7B%0A
+//
             
@@ -1957,16 +1957,18 @@
 esult);%0A
+//
         
@@ -1981,17 +1981,21 @@
       %7D%0A
-%0A
+//%0A//
         
@@ -2016,16 +2016,18 @@
 verride%0A
+//
         
@@ -2073,24 +2073,26 @@
 owable e) %7B%0A
+//
             
@@ -2116,32 +2116,34 @@
 ntStackTrace();%0A
+//
                 
@@ -2140,32 +2140,34 @@
               %7D%0A
+//
                 

Add to test