package cn.axzo.workflow.server.mq;

import cn.axzo.framework.rocketmq.Event;
import cn.axzo.framework.rocketmq.EventConsumer;
import cn.axzo.framework.rocketmq.EventHandler;
import cn.axzo.workflow.core.common.enums.FlowableEventModuleEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * TODO
 *
 * @author wangli
 * @since 2023/9/4 10:51
 */
@Slf4j
@Component
public class ProcessCreateListener implements EventHandler, InitializingBean {

    @Autowired
    private EventConsumer eventConsumer;

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

    @Override
    public void afterPropertiesSet() throws Exception {
        eventConsumer.registerHandler(FlowableEventModuleEnum.PROCESS_CREATED.getEventCode(), this);
    }
}
