switch(consumeFromWhere){case CONSUME_FROM_LAST_OFFSET_AND_FROM_MIN_WHEN_BOOT_FIRST:case CONSUME_FROM_MIN_OFFSET:case CONSUME_FROM_MAX_OFFSET:case CONSUME_FROM_LAST_OFFSET:{long lastOffset = offsetStore.readOffset(mq,ReadOffsetType.READ_FROM_STORE);if(lastOffset >=0){
result = lastOffset;}// First start,no offsetelseif(-1== lastOffset){if(mq.getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)){
result =0L;}else{try{
result =this.mQClientFactory.getMQAdminImpl().maxOffset(mq);}catch(MQClientException e){
result =-1;}}}else{
result =-1;}break;}case CONSUME_FROM_FIRST_OFFSET:{long lastOffset = offsetStore.readOffset(mq,ReadOffsetType.READ_FROM_STORE);if(lastOffset >=0){
result = lastOffset;}elseif(-1== lastOffset){
result =0L;}else{
result =-1;}break;}case CONSUME_FROM_TIMESTAMP:{long lastOffset = offsetStore.readOffset(mq,ReadOffsetType.READ_FROM_STORE);if(lastOffset >=0){
result = lastOffset;}elseif(-1== lastOffset){if(mq.getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)){try{
result =this.mQClientFactory.getMQAdminImpl().maxOffset(mq);}catch(MQClientException e){
result =-1;}}else{try{long timestamp =UtilAll.parseDate(this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer().getConsumeTimestamp(),UtilAll.YYYYMMDDHHMMSS).getTime();
result =this.mQClientFactory.getMQAdminImpl().searchOffset(mq, timestamp);}catch(MQClientException e){
result =-1;}}}else{
result =-1;}break;}default:break;}
posted on
2022-04-11 22:38路过君
阅读(257)
评论(0)
编辑收藏举报