RocketMq消息队列之削峰详解
RocketMq削峰
MQ的主要特点为解耦、异步、削峰,本篇博客只是简单的记录RocketMQ削峰用法,用于减少数据库压力的业务场景。
生产者,消费者的配置可以参考以前的文章,这里只列出消费者新增的两个配置:
@Bean(initMethod = "start", destroyMethod = "shutdown") public DefaultMQPushConsumer BatchConsumer() { DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(consumerBatchGroupName); consumer.setNamesrvAddr(nameServerAddress); consumer.setMaxReconsumeTimes(0); consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); consumer.registerMessageListener(messageListener); //consumer.setMessageModel(MessageModel.CLUSTERING);集群模式(默认) //consumer.setMessageModel(MessageModel.BROADCASTING);//广播模式 // 每次拉取的间隔,单位为毫秒 consumer.setPullInterval(10000); // 设置每次从队列中拉取的消息数为16 consumer.setPullBatchSize(1); try { consumer.subscribe(batchTopic, "*"); } catch (MQClientException e) { e.printStackTrace(); } return consumer; }
pullInterval:每次从Broker拉取消息的间隔,单位为毫秒
pullBatchSize:每次从Broker队列拉取到的消息数,该参数很容易让人误解,一开始我以为是每次拉取的消息总数,但测试过几次后确认了实质上是从每个队列的拉取数,即Consume每次拉取的消息总数如下:
EachPullTotal=所有Broker上的读/写队列数(broker数量*writeQueueNums或者readQueueNums) * pullBatchSize,这里我们简单演示所以只有一个Broker,Broker上的writeQueueNums=readQueueNums=16,pullBatchSize=1,所以每10秒拉取的数量为1*1*16=16条。
好了,我们现在往MQ中发送消息,观察单位时间间隔内的消费情况。
2020-06-06 10:15:07.145 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4880040, offsetMsgId=C0A8BE8300002A9F00000000000BCB7B, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=9], queueOffset=75]
2020-06-06 10:15:07.147 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F48A0041, offsetMsgId=C0A8BE8300002A9F00000000000BCC44, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=10], queueOffset=75]
2020-06-06 10:15:07.149 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F48B0042, offsetMsgId=C0A8BE8300002A9F00000000000BCD0D, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=11], queueOffset=77]
2020-06-06 10:15:07.150 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F48D0043, offsetMsgId=C0A8BE8300002A9F00000000000BCDD6, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=12], queueOffset=75]
2020-06-06 10:15:07.153 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F48E0044, offsetMsgId=C0A8BE8300002A9F00000000000BCE9F, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=13], queueOffset=76]
2020-06-06 10:15:07.154 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4910045, offsetMsgId=C0A8BE8300002A9F00000000000BCF68, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=14], queueOffset=77]
2020-06-06 10:15:07.157 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4930046, offsetMsgId=C0A8BE8300002A9F00000000000BD031, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=15], queueOffset=76]
2020-06-06 10:15:07.159 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4950047, offsetMsgId=C0A8BE8300002A9F00000000000BD0FA, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=0], queueOffset=76]
2020-06-06 10:15:07.160 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4970048, offsetMsgId=C0A8BE8300002A9F00000000000BD1C3, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=1], queueOffset=77]
2020-06-06 10:15:07.163 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4990049, offsetMsgId=C0A8BE8300002A9F00000000000BD28C, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=2], queueOffset=77]
2020-06-06 10:15:07.165 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F49B004A, offsetMsgId=C0A8BE8300002A9F00000000000BD358, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=3], queueOffset=76]
2020-06-06 10:15:07.167 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F49D004B, offsetMsgId=C0A8BE8300002A9F00000000000BD424, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=4], queueOffset=77]
2020-06-06 10:15:07.170 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4A0004C, offsetMsgId=C0A8BE8300002A9F00000000000BD4F0, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=5], queueOffset=77]
2020-06-06 10:15:07.174 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4A3004D, offsetMsgId=C0A8BE8300002A9F00000000000BD5BC, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=6], queueOffset=76]
2020-06-06 10:15:07.176 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4A6004E, offsetMsgId=C0A8BE8300002A9F00000000000BD688, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=7], queueOffset=75]
2020-06-06 10:15:07.178 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4A8004F, offsetMsgId=C0A8BE8300002A9F00000000000BD754, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=8], queueOffset=76]
2020-06-06 10:15:07.180 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4AB0050, offsetMsgId=C0A8BE8300002A9F00000000000BD820, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=9], queueOffset=76]
2020-06-06 10:15:07.182 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4AC0051, offsetMsgId=C0A8BE8300002A9F00000000000BD8EC, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=10], queueOffset=76]
2020-06-06 10:15:07.184 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4AF0052, offsetMsgId=C0A8BE8300002A9F00000000000BD9B8, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=11], queueOffset=78]
2020-06-06 10:15:07.187 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4B10053, offsetMsgId=C0A8BE8300002A9F00000000000BDA84, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=12], queueOffset=76]
2020-06-06 10:15:07.188 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4B30054, offsetMsgId=C0A8BE8300002A9F00000000000BDB50, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=13], queueOffset=77]
2020-06-06 10:15:07.189 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4B40055, offsetMsgId=C0A8BE8300002A9F00000000000BDC1C, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=14], queueOffset=78]
2020-06-06 10:15:07.191 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4B60056, offsetMsgId=C0A8BE8300002A9F00000000000BDCE8, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=15], queueOffset=77]
2020-06-06 10:15:07.192 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4B70057, offsetMsgId=C0A8BE8300002A9F00000000000BDDB4, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=0], queueOffset=77]
2020-06-06 10:15:07.194 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4B90058, offsetMsgId=C0A8BE8300002A9F00000000000BDE80, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=1], queueOffset=78]
2020-06-06 10:15:07.195 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4BA0059, offsetMsgId=C0A8BE8300002A9F00000000000BDF4C, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=2], queueOffset=78]
2020-06-06 10:15:07.196 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4BB005A, offsetMsgId=C0A8BE8300002A9F00000000000BE018, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=3], queueOffset=77]
2020-06-06 10:15:07.197 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4BC005B, offsetMsgId=C0A8BE8300002A9F00000000000BE0E4, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=4], queueOffset=78]
2020-06-06 10:15:07.198 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4BD005C, offsetMsgId=C0A8BE8300002A9F00000000000BE1B0, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=5], queueOffset=78]
2020-06-06 10:15:07.199 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4BE005D, offsetMsgId=C0A8BE8300002A9F00000000000BE27C, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=6], queueOffset=77]
2020-06-06 10:15:07.200 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4BF005E, offsetMsgId=C0A8BE8300002A9F00000000000BE348, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=7], queueOffset=76]
2020-06-06 10:15:07.201 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4C0005F, offsetMsgId=C0A8BE8300002A9F00000000000BE414, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=8], queueOffset=77]
2020-06-06 10:15:07.202 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4C10060, offsetMsgId=C0A8BE8300002A9F00000000000BE4E0, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=9], queueOffset=77]
2020-06-06 10:15:07.202 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4C20061, offsetMsgId=C0A8BE8300002A9F00000000000BE5AC, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=10], queueOffset=77]
2020-06-06 10:15:07.203 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4C20062, offsetMsgId=C0A8BE8300002A9F00000000000BE678, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=11], queueOffset=79]
2020-06-06 10:15:07.204 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4C30063, offsetMsgId=C0A8BE8300002A9F00000000000BE744, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=12], queueOffset=77]
2020-06-06 10:15:07.205 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4C40064, offsetMsgId=C0A8BE8300002A9F00000000000BE810, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=13], queueOffset=78]
2020-06-06 10:15:07.206 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4C50065, offsetMsgId=C0A8BE8300002A9F00000000000BE8DC, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=14], queueOffset=79]
2020-06-06 10:15:07.207 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4C60066, offsetMsgId=C0A8BE8300002A9F00000000000BE9A8, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=15], queueOffset=78]
2020-06-06 10:15:07.209 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4C70067, offsetMsgId=C0A8BE8300002A9F00000000000BEA74, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=0], queueOffset=78]
2020-06-06 10:15:07.210 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4C90068, offsetMsgId=C0A8BE8300002A9F00000000000BEB40, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=1], queueOffset=79]
2020-06-06 10:15:07.211 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4CA0069, offsetMsgId=C0A8BE8300002A9F00000000000BEC0C, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=2], queueOffset=79]
2020-06-06 10:15:07.212 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4CB006A, offsetMsgId=C0A8BE8300002A9F00000000000BECD8, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=3], queueOffset=78]
2020-06-06 10:15:07.212 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4CC006B, offsetMsgId=C0A8BE8300002A9F00000000000BEDA4, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=4], queueOffset=79]
2020-06-06 10:15:07.213 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4CC006C, offsetMsgId=C0A8BE8300002A9F00000000000BEE70, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=5], queueOffset=79]
2020-06-06 10:15:07.215 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4CD006D, offsetMsgId=C0A8BE8300002A9F00000000000BEF3C, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=6], queueOffset=78]
2020-06-06 10:15:07.215 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4CF006E, offsetMsgId=C0A8BE8300002A9F00000000000BF008, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=7], queueOffset=77]
2020-06-06 10:15:07.215 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4CF006F, offsetMsgId=C0A8BE8300002A9F00000000000BF0D4, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=8], queueOffset=78]
2020-06-06 10:15:07.216 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4CF0070, offsetMsgId=C0A8BE8300002A9F00000000000BF1A0, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=9], queueOffset=78]
2020-06-06 10:15:07.216 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4D00071, offsetMsgId=C0A8BE8300002A9F00000000000BF26C, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=10], queueOffset=78]
2020-06-06 10:15:07.218 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4D00072, offsetMsgId=C0A8BE8300002A9F00000000000BF338, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=11], queueOffset=80]
2020-06-06 10:15:07.219 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4D20073, offsetMsgId=C0A8BE8300002A9F00000000000BF404, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=12], queueOffset=78]
2020-06-06 10:15:07.219 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4D30074, offsetMsgId=C0A8BE8300002A9F00000000000BF4D0, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=13], queueOffset=79]
2020-06-06 10:15:07.219 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4D30075, offsetMsgId=C0A8BE8300002A9F00000000000BF59C, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=14], queueOffset=80]
2020-06-06 10:15:07.221 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4D30076, offsetMsgId=C0A8BE8300002A9F00000000000BF668, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=15], queueOffset=79]
2020-06-06 10:15:07.221 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4D50077, offsetMsgId=C0A8BE8300002A9F00000000000BF734, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=0], queueOffset=79]
2020-06-06 10:15:07.222 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4D50078, offsetMsgId=C0A8BE8300002A9F00000000000BF800, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=1], queueOffset=80]
2020-06-06 10:15:07.222 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4D60079, offsetMsgId=C0A8BE8300002A9F00000000000BF8CC, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=2], queueOffset=80]
2020-06-06 10:15:07.223 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4D6007A, offsetMsgId=C0A8BE8300002A9F00000000000BF998, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=3], queueOffset=79]
2020-06-06 10:15:07.224 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4D7007B, offsetMsgId=C0A8BE8300002A9F00000000000BFA64, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=4], queueOffset=80]
2020-06-06 10:15:07.226 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4D8007C, offsetMsgId=C0A8BE8300002A9F00000000000BFB30, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=5], queueOffset=80]
2020-06-06 10:15:07.229 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4DA007D, offsetMsgId=C0A8BE8300002A9F00000000000BFBFC, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=6], queueOffset=79]
2020-06-06 10:15:07.230 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4DD007E, offsetMsgId=C0A8BE8300002A9F00000000000BFCC8, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=7], queueOffset=78]
2020-06-06 10:15:07.231 INFO 15268 --- [nio-9001-exec-3] com.yj.mq.controller.MQController : SendResult:SendResult [sendStatus=SEND_OK, msgId=C0A8006B3BA4764C12B61BF2F4DE007F, offsetMsgId=C0A8BE8300002A9F00000000000BFD94, messageQueue=MessageQueue [topic=BATCH_CSDN, brokerName=localhost.localdomain, queueId=8], queueOffset=79]
2020-06-06 10:15:09.518 INFO 15268 --- [MessageThread_5] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:1_tag,body:{"desc":"1","orderId":1}
2020-06-06 10:15:09.518 INFO 15268 --- [MessageThread_3] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:2_tag,body:{"desc":"2","orderId":2}
2020-06-06 10:15:09.518 INFO 15268 --- [MessageThread_4] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:3_tag,body:{"desc":"3","orderId":3}
2020-06-06 10:15:09.519 INFO 15268 --- [MessageThread_8] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:4_tag,body:{"desc":"4","orderId":4}
2020-06-06 10:15:09.519 INFO 15268 --- [MessageThread_9] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:5_tag,body:{"desc":"5","orderId":5}
2020-06-06 10:15:09.538 INFO 15268 --- [essageThread_10] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:6_tag,body:{"desc":"6","orderId":6}
2020-06-06 10:15:09.538 INFO 15268 --- [essageThread_11] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:7_tag,body:{"desc":"7","orderId":7}
2020-06-06 10:15:09.573 INFO 15268 --- [essageThread_12] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:11_tag,body:{"desc":"11","orderId":11}
2020-06-06 10:15:09.573 INFO 15268 --- [MessageThread_2] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:13_tag,body:{"desc":"13","orderId":13}
2020-06-06 10:15:09.573 INFO 15268 --- [essageThread_13] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:9_tag,body:{"desc":"9","orderId":9}
2020-06-06 10:15:09.573 INFO 15268 --- [essageThread_14] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:12_tag,body:{"desc":"12","orderId":12}
2020-06-06 10:15:09.573 INFO 15268 --- [essageThread_15] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:8_tag,body:{"desc":"8","orderId":8}
2020-06-06 10:15:09.573 INFO 15268 --- [essageThread_16] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:10_tag,body:{"desc":"10","orderId":10}
2020-06-06 10:15:09.573 INFO 15268 --- [essageThread_18] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:14_tag,body:{"desc":"14","orderId":14}
2020-06-06 10:15:09.573 INFO 15268 --- [essageThread_19] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:16_tag,body:{"desc":"16","orderId":16}
2020-06-06 10:15:09.573 INFO 15268 --- [essageThread_17] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:15_tag,body:{"desc":"15","orderId":15}
2020-06-06 10:15:19.520 INFO 15268 --- [MessageThread_1] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:18_tag,body:{"desc":"18","orderId":18}
2020-06-06 10:15:19.520 INFO 15268 --- [essageThread_20] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:19_tag,body:{"desc":"19","orderId":19}
2020-06-06 10:15:19.520 INFO 15268 --- [MessageThread_6] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:17_tag,body:{"desc":"17","orderId":17}
2020-06-06 10:15:19.522 INFO 15268 --- [MessageThread_7] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:20_tag,body:{"desc":"20","orderId":20}
2020-06-06 10:15:19.522 INFO 15268 --- [MessageThread_5] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:21_tag,body:{"desc":"21","orderId":21}
2020-06-06 10:15:19.541 INFO 15268 --- [MessageThread_3] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:22_tag,body:{"desc":"22","orderId":22}
2020-06-06 10:15:19.541 INFO 15268 --- [MessageThread_4] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:23_tag,body:{"desc":"23","orderId":23}
2020-06-06 10:15:19.578 INFO 15268 --- [MessageThread_8] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:25_tag,body:{"desc":"25","orderId":25}
2020-06-06 10:15:19.578 INFO 15268 --- [essageThread_11] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:24_tag,body:{"desc":"24","orderId":24}
2020-06-06 10:15:19.578 INFO 15268 --- [essageThread_12] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:26_tag,body:{"desc":"26","orderId":26}
2020-06-06 10:15:19.578 INFO 15268 --- [MessageThread_8] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:30_tag,body:{"desc":"30","orderId":30}
2020-06-06 10:15:19.578 INFO 15268 --- [essageThread_12] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:32_tag,body:{"desc":"32","orderId":32}
2020-06-06 10:15:19.578 INFO 15268 --- [MessageThread_9] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:28_tag,body:{"desc":"28","orderId":28}
2020-06-06 10:15:19.579 INFO 15268 --- [essageThread_12] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:31_tag,body:{"desc":"31","orderId":31}
2020-06-06 10:15:19.578 INFO 15268 --- [essageThread_10] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:27_tag,body:{"desc":"27","orderId":27}
2020-06-06 10:15:19.578 INFO 15268 --- [essageThread_11] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:29_tag,body:{"desc":"29","orderId":29}
2020-06-06 10:15:29.526 INFO 15268 --- [essageThread_16] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:33_tag,body:{"desc":"33","orderId":33}
2020-06-06 10:15:29.526 INFO 15268 --- [essageThread_18] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:35_tag,body:{"desc":"35","orderId":35}
2020-06-06 10:15:29.527 INFO 15268 --- [essageThread_19] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:34_tag,body:{"desc":"34","orderId":34}
2020-06-06 10:15:29.527 INFO 15268 --- [essageThread_19] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:36_tag,body:{"desc":"36","orderId":36}
2020-06-06 10:15:29.527 INFO 15268 --- [MessageThread_1] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:37_tag,body:{"desc":"37","orderId":37}
2020-06-06 10:15:29.545 INFO 15268 --- [essageThread_20] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:38_tag,body:{"desc":"38","orderId":38}
2020-06-06 10:15:29.545 INFO 15268 --- [MessageThread_6] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:39_tag,body:{"desc":"39","orderId":39}
2020-06-06 10:15:29.585 INFO 15268 --- [MessageThread_7] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:41_tag,body:{"desc":"41","orderId":41}
2020-06-06 10:15:29.585 INFO 15268 --- [MessageThread_8] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:45_tag,body:{"desc":"45","orderId":45}
2020-06-06 10:15:29.585 INFO 15268 --- [MessageThread_5] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:43_tag,body:{"desc":"43","orderId":43}
2020-06-06 10:15:29.585 INFO 15268 --- [MessageThread_3] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:44_tag,body:{"desc":"44","orderId":44}
2020-06-06 10:15:29.585 INFO 15268 --- [MessageThread_4] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:40_tag,body:{"desc":"40","orderId":40}
2020-06-06 10:15:29.585 INFO 15268 --- [MessageThread_2] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:46_tag,body:{"desc":"46","orderId":46}
2020-06-06 10:15:29.585 INFO 15268 --- [essageThread_13] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:42_tag,body:{"desc":"42","orderId":42}
2020-06-06 10:15:29.585 INFO 15268 --- [essageThread_14] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:48_tag,body:{"desc":"48","orderId":48}
2020-06-06 10:15:29.585 INFO 15268 --- [essageThread_15] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:47_tag,body:{"desc":"47","orderId":47}
2020-06-06 10:15:39.528 INFO 15268 --- [MessageThread_9] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:49_tag,body:{"desc":"49","orderId":49}
2020-06-06 10:15:39.528 INFO 15268 --- [essageThread_10] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:51_tag,body:{"desc":"51","orderId":51}
2020-06-06 10:15:39.528 INFO 15268 --- [essageThread_12] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:50_tag,body:{"desc":"50","orderId":50}
2020-06-06 10:15:39.529 INFO 15268 --- [essageThread_11] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:52_tag,body:{"desc":"52","orderId":52}
2020-06-06 10:15:39.530 INFO 15268 --- [essageThread_16] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:53_tag,body:{"desc":"53","orderId":53}
2020-06-06 10:15:39.546 INFO 15268 --- [essageThread_18] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:54_tag,body:{"desc":"54","orderId":54}
2020-06-06 10:15:39.546 INFO 15268 --- [essageThread_17] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:55_tag,body:{"desc":"55","orderId":55}
2020-06-06 10:15:39.588 INFO 15268 --- [essageThread_19] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:57_tag,body:{"desc":"57","orderId":57}
2020-06-06 10:15:39.588 INFO 15268 --- [MessageThread_1] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:59_tag,body:{"desc":"59","orderId":59}
2020-06-06 10:15:39.588 INFO 15268 --- [essageThread_20] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:56_tag,body:{"desc":"56","orderId":56}
2020-06-06 10:15:39.588 INFO 15268 --- [essageThread_19] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:62_tag,body:{"desc":"62","orderId":62}
2020-06-06 10:15:39.588 INFO 15268 --- [MessageThread_1] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:64_tag,body:{"desc":"64","orderId":64}
2020-06-06 10:15:39.588 INFO 15268 --- [MessageThread_6] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:58_tag,body:{"desc":"58","orderId":58}
2020-06-06 10:15:39.588 INFO 15268 --- [essageThread_20] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:60_tag,body:{"desc":"60","orderId":60}
2020-06-06 10:15:39.588 INFO 15268 --- [MessageThread_5] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:63_tag,body:{"desc":"63","orderId":63}
2020-06-06 10:15:39.588 INFO 15268 --- [MessageThread_7] com.yj.mq.consumer.MessageProcessor : port:9001,消费Tag:61_tag,body:{"desc":"61","orderId":61}
我们一共发送了64条消息,发现每间隔10秒,每次消费16条数据。
到此这篇关于RocketMq消息队列之削峰详解的文章就介绍到这了,更多相关RocketMq削峰内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
idea中service或者mapper引入报红的问题及解决
在使用IntelliJ IDEA开发SpringBoot项目时,有时会遇到Service或Mapper接口引入时报红但不影响项目运行的情况,这主要是因为IDEA的检查级别设置问题,解决方法是将有问题的Error级别改为编译通过的安全级别,即可消除报红2024-09-09Java中comparator接口和Comparable接口的比较解析
这篇文章主要介绍了Java中comparator接口和Comparable接口的比较解析,Java提供了一个用于比较的接口Comparator和Comparable接口,提供了一个比较的方法,所有实现该接口的类,都动态的实现了该比较方法,需要的朋友可以参考下2023-08-08Spring Boot框架中的@Conditional注解示例详解
这篇文章主要介绍了Spring Boot框架中的@Conditional系列注解,@ConditionalOnProperty注解的作用是解析application.yml/application.properties 里的配置生成条件来生效,也是与@Configuration注解一起使用,本文通过示例代码给大家介绍的非常详细,需要的朋友一起看看吧2022-09-09
最新评论