problem description
there is a doubt about the example code of learning rocketmq on the official website. The link: http://rocketmq.apache.org/do... is the result of multiple if judgments in Subscription message sample code. What exactly does it mean?
related codes
/ / Please paste the code text below (do not replace the code with pictures)
consumer.registerMessageListener (new MessageListenerOrderly () {
AtomicLong consumeTimes = new AtomicLong(0);
@Override
public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs,
ConsumeOrderlyContext context) {
context.setAutoCommit(false);
System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n");
this.consumeTimes.incrementAndGet();
if ((this.consumeTimes.get() % 2) == 0) {
return ConsumeOrderlyStatus.SUCCESS;
} else if ((this.consumeTimes.get() % 3) == 0) {
return ConsumeOrderlyStatus.ROLLBACK;
} else if ((this.consumeTimes.get() % 4) == 0) {
return ConsumeOrderlyStatus.COMMIT;
} else if ((this.consumeTimes.get() % 5) == 0) {
context.setSuspendCurrentQueueTimeMillis(3000);
return ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT;
}
return ConsumeOrderlyStatus.SUCCESS;
}
});
what result do you expect? What is the error message actually seen?
ask Daniel to explain what those if values are supposed to mean. After watching it for a long time, I really don"t understand. Thank you!