package com.yeshi.buwan.util.mq.rabbit.consumer;
|
|
import com.rabbitmq.client.Channel;
|
import com.yeshi.buwan.service.inter.juhe.FunTV2Service;
|
import com.yeshi.buwan.util.mq.rabbit.RabbitmqMsgConsumeUtil;
|
import com.yeshi.buwan.videos.funtv.entity.FunTVAlbum2;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.amqp.core.Message;
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
import org.springframework.stereotype.Component;
|
import org.yeshi.utils.StringUtil;
|
|
import javax.annotation.Resource;
|
import java.nio.charset.StandardCharsets;
|
|
/**
|
* @author hxh
|
* @title: QueueHelloWorldListener
|
* @description:
|
* @date 2024/9/26 13:47
|
*/
|
@Component
|
public class VideoUpdateFuntv2Listener {
|
private final static Logger logger = LoggerFactory.getLogger(VideoUpdateFuntv2Listener.class);
|
|
@Resource
|
private RabbitTemplate rabbitTemplate;
|
|
@Resource
|
private FunTV2Service funTV2Service;
|
|
public void onMessage(Message message, Channel channel) throws Exception {
|
RabbitmqMsgConsumeUtil.processMessage(message, channel, rabbitTemplate, () -> {
|
String result = new String(message.getBody(), StandardCharsets.UTF_8);
|
if (!StringUtil.isNullOrEmpty(result)) {
|
try {
|
String mediaId = result;
|
FunTVAlbum2 album2 = funTV2Service.getAlbumDetail(mediaId);
|
if (album2 != null) {
|
funTV2Service.processAlbum(album2);
|
}
|
} catch (Exception e) {
|
logger.error("风行专辑添加到视频出错:" + e.getMessage());
|
logger.error("ID:" + result);
|
}
|
}
|
|
});
|
}
|
}
|