package com.elab.mq.rocket.msg;

import org.apache.rocketmq.client.hook.SendMessageContext;
import org.apache.rocketmq.client.hook.SendMessageHook;
import org.apache.rocketmq.client.producer.SendStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 默认的消息钩子
 *
 * @author ： liukx
 * @time ： 2019/7/18 - 16:43
 */
@Component
public class DefaultSendMessageHook implements SendMessageHook {

    private Logger logger = LoggerFactory.getLogger(DefaultSendMessageHook.class);

    @Override
    public String hookName() {
        return DefaultSendMessageHook.class.getName();
    }

    @Override
    public void sendMessageBefore(SendMessageContext context) {
        logger.info("-----------------------------------DefaultSendMessageHook---------sendMessageBefore----------------");
    }

    @Override
    public void sendMessageAfter(SendMessageContext context) {
        logger.info("-----------------------------------DefaultSendMessageHook---------sendMessageAfter----------------");
        SendStatus sendStatus = context.getSendResult().getSendStatus();
        String msgId = context.getSendResult().getMsgId();

    }
}
