package com.cool.store.mq.consumer.listener;

import com.aliyun.openservices.ons.api.Action;
import com.aliyun.openservices.ons.api.ConsumeContext;
import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.MessageListener;
import com.cool.store.constants.CommonConstants;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * 企业开通初始化
 *
 * @author chenyupeng
 * @since 2022/1/26
 */
@Slf4j
@Service
public class TestListener implements MessageListener {


    @Override
    public Action consume(Message message, ConsumeContext consumeContext) {
        if(message.getReconsumeTimes() + 1 >= Integer.parseInt(CommonConstants.MaxReconsumeTimes)){
            //超过最大消费次数
            return Action.CommitMessage;
        }
        String text = new String(message.getBody());
        log.info("text:{}", text);
        if(StringUtils.isBlank(text)){
            return Action.CommitMessage;
        }
        return Action.CommitMessage;
    }


}









