RocketMQ搭建链接:RockerMQ搭建
RocketMQ功能特性:
RocketMQ的介绍官网及网上一大堆,本文主要介绍应用场景,以及编写简单的代码样例
RocketMQ应用场景1:
我参与的上一个项目是一个网上电子税务系统,纳税人可以在网上通过此系统报税,简称系统a。纳税人还可以去税务厅通过排队纸质填表报税,税务厅使用的系统简称系统b。系统a和系统b所有的数据最终提交到系统c处理。系统c需要同事处理系统a和系统b的数据,如果是报税高峰期,系统c可能处理不过来。例如,李三通过系统a报税,填写了许多资料,花了大概半个小时,然后满意的点击了提交按钮,结果发现页面提示系统c繁忙,请刷新页面重新提交或者稍后提交。李三擦了擦汗,刷新了一下,发现还好之间填的数据系统有缓存还在,于是又点击了一次提交。然后页面还是提示系统c繁忙。于是他只能等到半夜人少的时候再来提交数据。
场景分析:报税高峰期,系统c由于并发量太大,会出现处理系统a和系统b的数据时间缓慢,导致用户重复提交,导致大量来自系统a和系统b的请求被积压,最后可能导致系统c瘫痪。
解决方案:我们公司负责系统a,于是我们在系统a使用了RocketMQ中间件,用户提交数据的时候,先发送提交的数据到RocketMQ,当系统c出现处理数据并发量过大(可以通过监控处理数据的时间等手段),系统a就减少提交到系统c的并发量数据。使用ROcketMQ之后,李三在报税高峰期提交数据,发现页面提示:“您提交的请求正在排队处理中,您可以关闭页面,数据提交成功后会以短信的形式发送给您!”李三看到提示开心的关掉了网页,过了一会手机收到税务局短信提示报税成功。
RocketMQ应用场景2:
张三在微信小程序买了一件商品,支付成功后系统需要从他的账户减去30元金额,商家的账号需要增加30元金额。这个过程涉及到了大量的数据验证系统交互,假设支付成功后系统给张三账户减去30元金额花费0.5秒,然后系统再给商家账户增加30元金额也需要花费0.5秒,那么整个过程就需要花费1秒。如果系统1秒内只能处理10000个用户的请求,那么第10001个用户的请求就会被拒绝。使用RocketMQ将购买商品支付账户操作拆分为两个过程,过程一:“张三账户减30元,将这个消息发送到RocketMQ,数据库减去30元后不再管商家是否账户已经收到30元”,过程二::”系统消费RocketMQ的消息,进行商家账户加30元的操作“。这样让两个过程并行运行,系统处理整个过程就变成了0.5秒,提高了吞吐量。使用RocketMQ是基于它的可靠性,就是说整个过程中消息发送成功率为%99.9,剩下的很小的错误概率可以通过日记等记录人工处理。
第一步:项目导入RoketMQ的包
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
<version>4.3.0</version>
</dependency>
代码:
public static void main(String [] args) throws MQClientException, RemotingException, InterruptedException, MQBrokerException {
DefaultMQProducer producer = new DefaultMQProducer("test_quick_producer_name");
//端口号一般是使用9876,Const.NAMESRV_ADDR=106.13.88.XXX:19876
producer.setNamesrvAddr(Const.NAMESRV_ADDR);
producer.start();
for(int i = 0; i <6; ++i ){
Message message = new Message("topic_quick_test",
"tag_quick_test","key"+i,("hello quick_start!"+i).getBytes());
SendResult sendResult = producer.send(message);
System.out.println("发送的消息为:"+sendResult);
}
//消息发完了得关闭
producer.shutdown();
}
控制台打印消息为:
queueId表示消息使用第几个队列发送,默认为4个队列
"C:\Program Files\Java\jdk1.8.0_111\bin\java.exe" "-javaagent:D:\IDEA\IntelliJ IDEA 2019.3.1\lib\idea_rt.jar=51884:D:\IDEA\IntelliJ IDEA 2019.3.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_111\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\rt.jar;E:\学习资料视频\rocketMQ\rocketmq-externals-master\rocketmq-test\target\classes;C:\Users\96935\.m2\repository\org\springframework\boot\spring-boot-starter-web\2.2.6.RELEASE\spring-boot-starter-web-2.2.6.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\boot\spring-boot-starter\2.2.6.RELEASE\spring-boot-starter-2.2.6.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\boot\spring-boot\2.2.6.RELEASE\spring-boot-2.2.6.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.2.6.RELEASE\spring-boot-autoconfigure-2.2.6.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.2.6.RELEASE\spring-boot-starter-logging-2.2.6.RELEASE.jar;C:\Users\96935\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\96935\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\96935\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.12.1\log4j-to-slf4j-2.12.1.jar;C:\Users\96935\.m2\repository\org\apache\logging\log4j\log4j-api\2.12.1\log4j-api-2.12.1.jar;C:\Users\96935\.m2\repository\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;C:\Users\96935\.m2\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\Users\96935\.m2\repository\org\yaml\snakeyaml\1.25\snakeyaml-1.25.jar;C:\Users\96935\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.2.6.RELEASE\spring-boot-starter-json-2.2.6.RELEASE.jar;C:\Users\96935\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.10.3\jackson-databind-2.10.3.jar;C:\Users\96935\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.10.3\jackson-annotations-2.10.3.jar;C:\Users\96935\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.10.3\jackson-core-2.10.3.jar;C:\Users\96935\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.10.3\jackson-datatype-jdk8-2.10.3.jar;C:\Users\96935\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.10.3\jackson-datatype-jsr310-2.10.3.jar;C:\Users\96935\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.10.3\jackson-module-parameter-names-2.10.3.jar;C:\Users\96935\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\2.2.6.RELEASE\spring-boot-starter-tomcat-2.2.6.RELEASE.jar;C:\Users\96935\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.33\tomcat-embed-core-9.0.33.jar;C:\Users\96935\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\9.0.33\tomcat-embed-el-9.0.33.jar;C:\Users\96935\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.33\tomcat-embed-websocket-9.0.33.jar;C:\Users\96935\.m2\repository\org\springframework\boot\spring-boot-starter-validation\2.2.6.RELEASE\spring-boot-starter-validation-2.2.6.RELEASE.jar;C:\Users\96935\.m2\repository\jakarta\validation\jakarta.validation-api\2.0.2\jakarta.validation-api-2.0.2.jar;C:\Users\96935\.m2\repository\org\hibernate\validator\hibernate-validator\6.0.18.Final\hibernate-validator-6.0.18.Final.jar;C:\Users\96935\.m2\repository\org\jboss\logging\jboss-logging\3.4.1.Final\jboss-logging-3.4.1.Final.jar;C:\Users\96935\.m2\repository\com\fasterxml\classmate\1.5.1\classmate-1.5.1.jar;C:\Users\96935\.m2\repository\org\springframework\spring-web\5.2.5.RELEASE\spring-web-5.2.5.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\spring-beans\5.2.5.RELEASE\spring-beans-5.2.5.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\spring-webmvc\5.2.5.RELEASE\spring-webmvc-5.2.5.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\spring-aop\5.2.5.RELEASE\spring-aop-5.2.5.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\spring-context\5.2.5.RELEASE\spring-context-5.2.5.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\spring-expression\5.2.5.RELEASE\spring-expression-5.2.5.RELEASE.jar;C:\Users\96935\.m2\repository\org\mybatis\spring\boot\mybatis-spring-boot-starter\2.1.2\mybatis-spring-boot-starter-2.1.2.jar;C:\Users\96935\.m2\repository\org\springframework\boot\spring-boot-starter-jdbc\2.2.6.RELEASE\spring-boot-starter-jdbc-2.2.6.RELEASE.jar;C:\Users\96935\.m2\repository\com\zaxxer\HikariCP\3.4.2\HikariCP-3.4.2.jar;C:\Users\96935\.m2\repository\org\springframework\spring-jdbc\5.2.5.RELEASE\spring-jdbc-5.2.5.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\spring-tx\5.2.5.RELEASE\spring-tx-5.2.5.RELEASE.jar;C:\Users\96935\.m2\repository\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\2.1.2\mybatis-spring-boot-autoconfigure-2.1.2.jar;C:\Users\96935\.m2\repository\org\mybatis\mybatis\3.5.4\mybatis-3.5.4.jar;C:\Users\96935\.m2\repository\org\mybatis\mybatis-spring\2.0.4\mybatis-spring-2.0.4.jar;C:\Users\96935\.m2\repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;C:\Users\96935\.m2\repository\org\apache\rocketmq\rocketmq-client\4.3.0\rocketmq-client-4.3.0.jar;C:\Users\96935\.m2\repository\org\apache\rocketmq\rocketmq-common\4.3.0\rocketmq-common-4.3.0.jar;C:\Users\96935\.m2\repository\org\apache\rocketmq\rocketmq-remoting\4.3.0\rocketmq-remoting-4.3.0.jar;C:\Users\96935\.m2\repository\com\alibaba\fastjson\1.2.29\fastjson-1.2.29.jar;C:\Users\96935\.m2\repository\io\netty\netty-all\4.1.48.Final\netty-all-4.1.48.Final.jar;C:\Users\96935\.m2\repository\org\apache\rocketmq\rocketmq-logging\4.3.0\rocketmq-logging-4.3.0.jar;C:\Users\96935\.m2\repository\io\netty\netty-tcnative-boringssl-static\2.0.30.Final\netty-tcnative-boringssl-static-2.0.30.Final.jar;C:\Users\96935\.m2\repository\org\apache\commons\commons-lang3\3.9\commons-lang3-3.9.jar;C:\Users\96935\.m2\repository\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;C:\Users\96935\.m2\repository\org\springframework\spring-core\5.2.5.RELEASE\spring-core-5.2.5.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\spring-jcl\5.2.5.RELEASE\spring-jcl-5.2.5.RELEASE.jar" com.xy.rocketmqtest.quickstart.Producer
发送的消息为:SendResult [sendStatus=SEND_OK, msgId=C0A800653DF018B4AAC264C3B2B00000, offsetMsgId=6A0D58D300002A9F0000000000000000, messageQueue=MessageQueue [topic=topic_quick_test, brokerName=broker-a, queueId=3], queueOffset=0]
发送的消息为:SendResult [sendStatus=SEND_OK, msgId=C0A800653DF018B4AAC264C3B3710001, offsetMsgId=6A0D58D300002A9F00000000000000D0, messageQueue=MessageQueue [topic=topic_quick_test, brokerName=broker-a, queueId=0], queueOffset=0]
发送的消息为:SendResult [sendStatus=SEND_OK, msgId=C0A800653DF018B4AAC264C3B3A20002, offsetMsgId=6A0D58D300002A9F00000000000001A0, messageQueue=MessageQueue [topic=topic_quick_test, brokerName=broker-a, queueId=1], queueOffset=0]
发送的消息为:SendResult [sendStatus=SEND_OK, msgId=C0A800653DF018B4AAC264C3B3D50003, offsetMsgId=6A0D58D300002A9F0000000000000270, messageQueue=MessageQueue [topic=topic_quick_test, brokerName=broker-a, queueId=2], queueOffset=0]
发送的消息为:SendResult [sendStatus=SEND_OK, msgId=C0A800653DF018B4AAC264C3B4050004, offsetMsgId=6A0D58D300002A9F0000000000000340, messageQueue=MessageQueue [topic=topic_quick_test, brokerName=broker-a, queueId=3], queueOffset=1]
发送的消息为:SendResult [sendStatus=SEND_OK, msgId=C0A800653DF018B4AAC264C3B4350005, offsetMsgId=6A0D58D300002A9F0000000000000410, messageQueue=MessageQueue [topic=topic_quick_test, brokerName=broker-a, queueId=0], queueOffset=1]
13:35:47.403 [NettyClientSelector_1] INFO RocketmqRemoting - closeChannel: close the connection to remote address[106.13.88.211:10909] result: true
13:35:47.408 [NettyClientSelector_1] INFO RocketmqRemoting - closeChannel: close the connection to remote address[106.13.88.211:10911] result: true
13:35:47.409 [NettyClientSelector_1] INFO RocketmqRemoting - closeChannel: close the connection to remote address[106.13.88.211:19876] result: true
Process finished with exit code 0
在控制台可以看到发送到RocketMQ的消息
第二部分:消费消息
public static void main(String[] args) throws MQClientException {
DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("test_quick_comsumer_name");
//端口号一般是使用9876,Const.NAMESRV_ADDR=106.13.88.XXX:19876
consumer.setNamesrvAddr(Const.NAMESRV_ADDR);
//从那个位置开始消费,可以从末尾,最前端 这里是最末尾
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET);
//消费哪个主题的消息和标签,标签可以是表达式,如*表示消费该topic下的所有类型标签的消息
consumer.subscribe("topic_quick_test","tag_quick_test");
consumer.registerMessageListener(new MessageListenerConcurrently() {
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) {
MessageExt me = msgs.get(0);
try{
String topic = me.getTopic();
String tags = me.getTags();
String keys =me.getKeys();
if(keys.equals("key3")){
System.out.println("模拟消费失败*********");
int a = 1/0;
}
String body = new String(me.getBody(), "UTF-8");
System.out.println("test_quick消费消息:topic:"+topic+"tags:"+tags+"keys:"+keys+"body:"+body);
}catch (Exception e){
e.printStackTrace();
int reconsumerTimes = me.getReconsumeTimes();
System.out.println("第"+reconsumerTimes+"次消费该消息!");
if(reconsumerTimes==4){
//如果消费四次还没有消费到就做日志,然后做补偿
}
//消费失败会重新消费,时间从1s 开始然后越来越长,到最后一次重试的时间是2h 默认重试15次
return ConsumeConcurrentlyStatus.RECONSUME_LATER;
}
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
});
consumer.start();
}
控制台打印消息:
代码块
```"C:\Program Files\Java\jdk1.8.0_111\bin\java.exe" "-javaagent:D:\IDEA\IntelliJ IDEA 2019.3.1\lib\idea_rt.jar=58032:D:\IDEA\IntelliJ IDEA 2019.3.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_111\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\rt.jar;E:\学习资料视频\rocketMQ\rocketmq-externals-master\rocketmq-test\target\classes;C:\Users\96935\.m2\repository\org\springframework\boot\spring-boot-starter-web\2.2.6.RELEASE\spring-boot-starter-web-2.2.6.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\boot\spring-boot-starter\2.2.6.RELEASE\spring-boot-starter-2.2.6.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\boot\spring-boot\2.2.6.RELEASE\spring-boot-2.2.6.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.2.6.RELEASE\spring-boot-autoconfigure-2.2.6.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.2.6.RELEASE\spring-boot-starter-logging-2.2.6.RELEASE.jar;C:\Users\96935\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\96935\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\96935\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.12.1\log4j-to-slf4j-2.12.1.jar;C:\Users\96935\.m2\repository\org\apache\logging\log4j\log4j-api\2.12.1\log4j-api-2.12.1.jar;C:\Users\96935\.m2\repository\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;C:\Users\96935\.m2\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\Users\96935\.m2\repository\org\yaml\snakeyaml\1.25\snakeyaml-1.25.jar;C:\Users\96935\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.2.6.RELEASE\spring-boot-starter-json-2.2.6.RELEASE.jar;C:\Users\96935\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.10.3\jackson-databind-2.10.3.jar;C:\Users\96935\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.10.3\jackson-annotations-2.10.3.jar;C:\Users\96935\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.10.3\jackson-core-2.10.3.jar;C:\Users\96935\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.10.3\jackson-datatype-jdk8-2.10.3.jar;C:\Users\96935\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.10.3\jackson-datatype-jsr310-2.10.3.jar;C:\Users\96935\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.10.3\jackson-module-parameter-names-2.10.3.jar;C:\Users\96935\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\2.2.6.RELEASE\spring-boot-starter-tomcat-2.2.6.RELEASE.jar;C:\Users\96935\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.33\tomcat-embed-core-9.0.33.jar;C:\Users\96935\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\9.0.33\tomcat-embed-el-9.0.33.jar;C:\Users\96935\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.33\tomcat-embed-websocket-9.0.33.jar;C:\Users\96935\.m2\repository\org\springframework\boot\spring-boot-starter-validation\2.2.6.RELEASE\spring-boot-starter-validation-2.2.6.RELEASE.jar;C:\Users\96935\.m2\repository\jakarta\validation\jakarta.validation-api\2.0.2\jakarta.validation-api-2.0.2.jar;C:\Users\96935\.m2\repository\org\hibernate\validator\hibernate-validator\6.0.18.Final\hibernate-validator-6.0.18.Final.jar;C:\Users\96935\.m2\repository\org\jboss\logging\jboss-logging\3.4.1.Final\jboss-logging-3.4.1.Final.jar;C:\Users\96935\.m2\repository\com\fasterxml\classmate\1.5.1\classmate-1.5.1.jar;C:\Users\96935\.m2\repository\org\springframework\spring-web\5.2.5.RELEASE\spring-web-5.2.5.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\spring-beans\5.2.5.RELEASE\spring-beans-5.2.5.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\spring-webmvc\5.2.5.RELEASE\spring-webmvc-5.2.5.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\spring-aop\5.2.5.RELEASE\spring-aop-5.2.5.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\spring-context\5.2.5.RELEASE\spring-context-5.2.5.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\spring-expression\5.2.5.RELEASE\spring-expression-5.2.5.RELEASE.jar;C:\Users\96935\.m2\repository\org\mybatis\spring\boot\mybatis-spring-boot-starter\2.1.2\mybatis-spring-boot-starter-2.1.2.jar;C:\Users\96935\.m2\repository\org\springframework\boot\spring-boot-starter-jdbc\2.2.6.RELEASE\spring-boot-starter-jdbc-2.2.6.RELEASE.jar;C:\Users\96935\.m2\repository\com\zaxxer\HikariCP\3.4.2\HikariCP-3.4.2.jar;C:\Users\96935\.m2\repository\org\springframework\spring-jdbc\5.2.5.RELEASE\spring-jdbc-5.2.5.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\spring-tx\5.2.5.RELEASE\spring-tx-5.2.5.RELEASE.jar;C:\Users\96935\.m2\repository\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\2.1.2\mybatis-spring-boot-autoconfigure-2.1.2.jar;C:\Users\96935\.m2\repository\org\mybatis\mybatis\3.5.4\mybatis-3.5.4.jar;C:\Users\96935\.m2\repository\org\mybatis\mybatis-spring\2.0.4\mybatis-spring-2.0.4.jar;C:\Users\96935\.m2\repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;C:\Users\96935\.m2\repository\org\apache\rocketmq\rocketmq-client\4.3.0\rocketmq-client-4.3.0.jar;C:\Users\96935\.m2\repository\org\apache\rocketmq\rocketmq-common\4.3.0\rocketmq-common-4.3.0.jar;C:\Users\96935\.m2\repository\org\apache\rocketmq\rocketmq-remoting\4.3.0\rocketmq-remoting-4.3.0.jar;C:\Users\96935\.m2\repository\com\alibaba\fastjson\1.2.29\fastjson-1.2.29.jar;C:\Users\96935\.m2\repository\io\netty\netty-all\4.1.48.Final\netty-all-4.1.48.Final.jar;C:\Users\96935\.m2\repository\org\apache\rocketmq\rocketmq-logging\4.3.0\rocketmq-logging-4.3.0.jar;C:\Users\96935\.m2\repository\io\netty\netty-tcnative-boringssl-static\2.0.30.Final\netty-tcnative-boringssl-static-2.0.30.Final.jar;C:\Users\96935\.m2\repository\org\apache\commons\commons-lang3\3.9\commons-lang3-3.9.jar;C:\Users\96935\.m2\repository\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;C:\Users\96935\.m2\repository\org\springframework\spring-core\5.2.5.RELEASE\spring-core-5.2.5.RELEASE.jar;C:\Users\96935\.m2\repository\org\springframework\spring-jcl\5.2.5.RELEASE\spring-jcl-5.2.5.RELEASE.jar" com.xy.rocketmqtest.quickstart.Consumer
test_quick消费消息:topic:topic_quick_testtags:tag_quick_testkeys:key0body:hello quick_start!0
test_quick消费消息:topic:topic_quick_testtags:tag_quick_testkeys:key1body:hello quick_start!1
test_quick消费消息:topic:topic_quick_testtags:tag_quick_testkeys:key2body:hello quick_start!2
模拟消费失败*********
第0次消费该消息!
java.lang.ArithmeticException: / by zero
at com.xy.rocketmqtest.quickstart.Consumer$1.consumeMessage(Consumer.java:35)
at org.apache.rocketmq.client.impl.consumer.ConsumeMessageConcurrentlyService$ConsumeRequest.run(ConsumeMessageConcurrentlyService.java:417)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
test_quick消费消息:topic:topic_quick_testtags:tag_quick_testkeys:key4body:hello quick_start!4
test_quick消费消息:topic:topic_quick_testtags:tag_quick_testkeys:key5body:hello quick_start!5
模拟消费失败*********
第1次消费该消息!
java.lang.ArithmeticException: / by zero
at com.xy.rocketmqtest.quickstart.Consumer$1.consumeMessage(Consumer.java:35)
at org.apache.rocketmq.client.impl.consumer.ConsumeMessageConcurrentlyService$ConsumeRequest.run(ConsumeMessageConcurrentlyService.java:417)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
模拟消费失败*********
第2次消费该消息!
java.lang.ArithmeticException: / by zero
at com.xy.rocketmqtest.quickstart.Consumer$1.consumeMessage(Consumer.java:35)
at org.apache.rocketmq.client.impl.consumer.ConsumeMessageConcurrentlyService$ConsumeRequest.run(ConsumeMessageConcurrentlyService.java:417)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)