package cn.axzo.msg.center.mq;

import cn.axzo.framework.rocketmq.Event;
import cn.axzo.framework.rocketmq.EventConsumer;
import cn.axzo.framework.rocketmq.EventHandler;
import cn.axzo.msg.center.service.enums.MqMessageType;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

/**
 * @author yanglin
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class TestMessageHandler implements EventHandler, InitializingBean {

    private final EventConsumer eventConsumer;

    @Override
    public void onEvent(Event event, EventConsumer.Context context) {
        log.info("Received test message: {}", event);
    }

    @Override
    public void afterPropertiesSet() {
        eventConsumer.registerHandler(MqMessageType.TODO_TEST_MESSAGE.getEventCode(), this);
    }

}
