UcEngineManagement2IptvConsumer.java
3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package com.topdraw.mq.consumer;
import com.rabbitmq.client.Channel;
import com.topdraw.exception.BadRequestException;
import com.topdraw.mq.domain.TableOperationMsg;
import com.topdraw.util.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.io.IOException;
@Component
@Slf4j
public class UcEngineManagement2IptvConsumer {
@Autowired
private AutoRoute autoUser;
// @Value("#{rabbitMqErrorLogConfig.getUceError()}")
// private Map<String, String> error;
/*@RabbitHandler
@RabbitListener(queues = "#{rabbitMqSourceConfig.getMemberInfoAsyncQueue()}",
//containerFactory = "#{rabbitMqSourceConfig.getUceSource()}",
// autoStartup = "#{rabbitMqSourceConfig.getUceStartUp()}",
ackMode = "AUTO")*/
@RabbitHandler
@RabbitListener(queues = "#{rabbitMqConfig.getMemberInfoQueue()}",
ackMode = "AUTO")
@Deprecated
public void memberInfoConsumer(Channel channel, Message message, String content) throws IOException {
// TODO 已废弃
log.info("同步会员信息,参数 memberInfoConsumer# ==>> {} ", content);
try {
if (StringUtils.isEmpty(content)) {
throw new BadRequestException("无参数");
}
TableOperationMsg tableOperationMsg = JSONUtil.parseMsg2Object(content,TableOperationMsg.class);
log.info("同步会员信息,解析参数后的结果,memberInfoConsumer# ==>> {}", tableOperationMsg);
this.autoUser.route(tableOperationMsg);
// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (Exception e) {
log.error("消费uc-engine消息失败, memberInfoConsumer# message ==>> {}", e.getMessage());
// channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
}
}
/**
* 事件
* @param content
* @description 基础数据同步
* @author Hongyan Wang
* @date 2021/9/7 11:26 上午
*/
/*@RabbitHandler
@RabbitListener(queues = "#{rabbitMqSourceConfig.getUceQueue()}",
containerFactory = "#{rabbitMqSourceConfig.getUceSource()}",
autoStartup = "#{rabbitMqSourceConfig.getUceStartUp()}",
ackMode = "MANUAL")*/
@RabbitHandler
@RabbitListener(queues = "#{rabbitMqConfig.getUceQueue()}", ackMode = "AUTO")
public void ucEngineConsumer(Channel channel, Message message, String content) throws IOException {
log.info("消费uc-engine信息,参数 ucEngineConsumer# content ==>> {} ", content);
try {
if (StringUtils.isEmpty(content)) {
throw new BadRequestException("无参数");
}
TableOperationMsg tableOperationMsg = JSONUtil.parseMsg2Object(content,TableOperationMsg.class);
log.info("同步会员信息,解析参数后的结果,memberInfoConsumer# ==>> {}", tableOperationMsg);
this.autoUser.route(tableOperationMsg);
// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (Exception e) {
log.error("消费uc-engine消息失败, cause ==>> [ucEngineConsumer#{}]", e.getMessage());
// channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
}
}
}