package uzi9.cosmic.debug;

import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.mq.MessageAcker;
import kd.bos.mq.MessageConsumer;

/**
 * @BelongsProject: uzi9-cosmic
 * @BelongsPackage: uzi9.cosmic.debug
 * @Author: lhbj
 * @CreateTime: 2025-09-12  14:23
 * @Description: TODO
 * @Version: 1.0
 */
public class DemoConsumer implements MessageConsumer {
    private final Log log = LogFactory.getLog(getClass());

    @Override
    public void onMessage(Object id, String messageId, boolean resend, MessageAcker acker) {
        log.info("DemoConsumer onMessage demo 开始消费。");
        try {

            acker.ack(messageId);
            boolean discard =false;
            String msg = (String) id;
            if("mq发送消息。".equals(msg)){
                discard =true;
            }

            if (discard) {
                acker.discard(messageId);
                log.info(id + "已经审核，此消息丢弃");
            } else {
                acker.deny(messageId);
            }
        } catch (Exception e) {
            acker.deny(messageId);
            log.error(e);
        }


    }

    @Override
    public String getRouteKey() {
        return MessageConsumer.super.getRouteKey();
    }
}