package com.yeshi.buwan.util.mq.rabbit; import com.google.gson.Gson; import com.yeshi.buwan.dto.mq.*; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; /** * @author hxh * @title: RabbitmqManager * @description: 消息管理 * @date 2024/10/14 10:19 */ @Component public class RabbitmqManager { // 搜索引擎 public static String QUEUENAME_SOLR = "buwan-solr-new"; //视频更新-爱奇艺2 public static String QUEUENAME_VIDEO_UPDATE_IQIYI_2 = "buwan-video-update-iqiyi2"; //视频更新-风行2 public static String QUEUENAME_VIDEO_UPDATE_FUNTV_2 = "buwan-video-update-funtv2"; //视频更新-PPTV public static String QUEUENAME_VIDEO_UPDATE_PPTV = "buwan-video-update-pptv"; //删除视频资源 public static String QUEUENAME_VIDEO_RESOURCE_DELETE = "buwan-video-resource-delete"; //更新视频附加信息 public static String QUEUENAME_UPDATE_VIDEO_EXTRAINFO = "buwan-video-video-update-extrainfo"; //全网搜 public static String QUEUENAME_UPDATE_INTERNET_SEARCH = "buwan-video-update-internet-search"; public static String QUEUENAME_UPDATE_RESOURCE_VIDEO = "buwan-video-update-resource-video"; //同步V2版本的视频信息 public static String QUEUENAME_VIDEO_SYNCDATA_V2 = "buwan-video-syncdata-v2"; public static String TOPIC_VIDEO_EXTRAINFO = "buwan_topic_video_extrainfo_change"; //视频信息修改 public static String TOPIC_VIDEO_INFO_CHANGE = "buwan_topic_video_info_change"; @Resource private RabbitTemplate rabbitTemplate; //添加专辑更新消息 public void addIqiyiAlbumUpdateMsg(Long id) { RabbitmqSenderUtil.sendQueueMsg(rabbitTemplate, QUEUENAME_VIDEO_UPDATE_IQIYI_2, id + ""); } //添加专辑更新消息 public void addPPTVSeriesUpdateMsg(PPTVMQMsg msg) { RabbitmqSenderUtil.sendQueueMsg(rabbitTemplate, QUEUENAME_VIDEO_UPDATE_PPTV, new Gson().toJson(msg)); } public void addSolrMsg(String id) { RabbitmqSenderUtil.sendQueueMsg(rabbitTemplate, QUEUENAME_SOLR, id); } public void addVideoResourceDeleteMsg(String videoId) { RabbitmqSenderUtil.sendQueueMsg(rabbitTemplate, QUEUENAME_VIDEO_RESOURCE_DELETE, videoId); } /** * 视频附加信息改变 */ public void addVideoExtraInfoChanged(VideoExtraInfoChangeMQMsg msg) { RabbitmqSenderUtil.sendExchangeMsg(rabbitTemplate, TOPIC_VIDEO_EXTRAINFO, "*", new Gson().toJson(msg)); } /** * 全网搜 * * @param msg */ public void addInternetSearchVideoUpdateMsg(InternetSearchVideoMQMsg msg) { RabbitmqSenderUtil.sendQueueMsg(rabbitTemplate, QUEUENAME_UPDATE_INTERNET_SEARCH, new Gson().toJson(msg)); } /** * 视频来源更新 * * @param msg */ public void addUpdateResourceVideoMsg(UpdateResourceVideoMQMsg msg) { RabbitmqSenderUtil.sendQueueMsg(rabbitTemplate, QUEUENAME_UPDATE_RESOURCE_VIDEO, new Gson().toJson(msg)); } //视频数据更改 public void addVideoDataChanged(VideoDataChangeMQMsg msg) { RabbitmqSenderUtil.sendExchangeMsg(rabbitTemplate, TOPIC_VIDEO_INFO_CHANGE, "*", new Gson().toJson(msg)); } }