1 package cn.wh.work; 2 3 import cn.wh.util.RabbitMqConnectionUtil; 4 import com.rabbitmq.client.Channel; 5 import com.rabbitmq.client.Connection; 6 7 public class Send { 8 private static final String QUEVE_NAME = "test_work_queue"; 9 10 public static void main(String[] args) throws Exception { 11 ; 12 Connection connection = RabbitMqConnectionUtil.getConnection(); 13 Channel channel = connection.createChannel(); 14 channel.queueDeclare(QUEVE_NAME, false, false, false, null); 15 16 int i1 =1 ; 17 channel.basicQos(i1); 18 for (int i = 0; i < 50; i++) { 19 String msg = "hello " + i; 20 System.out.println(msg); 21 channel.basicPublish("", QUEVE_NAME, null, msg.getBytes()); 22 Thread.sleep(i * 20); 23 } 24 channel.close(); 25 connection.close(); 26 } 27 }
工作队列work queues 公平分发(fair dispatch) And 消息应答与消息持久化
内容版权声明:除非注明,否则皆为本站原创文章。