package com.muyu.carData.pulisher;

import com.alibaba.fastjson.JSONObject;
import com.muyu.carData.event.EsSaveEvent;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

/**事件发布测试
 * @Author：张腾
 * @Package：com.muyu.carData.pulisher
 * @Project：cloud-server-8
 * @name：CustomEventPublisher
 * @Date：2024/9/29 23:51
 */
@Log4j2
@Component
@AllArgsConstructor
public class CustomEventPublisher {

    private ApplicationEventPublisher applicationEventPublisher;

    public void publish(JSONObject data){
        EsSaveEvent esSaveEvent = new EsSaveEvent(data);
        applicationEventPublisher.publishEvent(esSaveEvent);
        log.info("事件发布成功 - 消息是:{}",data);
    }
}
