xiaoyong931011
2021-03-04 6bfa9de6c86de3b6de5d59e0dc9eebbba13bdb1f
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
package com.xcong.excoin.rabbit.consumer;
 
import com.rabbitmq.client.Channel;
import com.xcong.excoin.configurations.RabbitMqConfig;
import com.xcong.excoin.modules.documentary.service.FollowOrderOperationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
 
/**
 * @author wzy
 * @date 2021-03-04
 **/
@Slf4j
@Component
@ConditionalOnProperty(prefix = "app", name = "rabbit-consumer", havingValue = "true")
public class FollowConsumer {
 
    @Autowired
    private FollowOrderOperationService followOrderOperationService;
 
    @RabbitListener(queues = RabbitMqConfig.QUEUE_FOLLOW_ORDER)
    public void addFollowOrder(Message message, Channel channel) {
        String content = new String(message.getBody());
        log.info("==收到跟单下单消息 : {}", content);
        followOrderOperationService.addFollowerOrder(Long.parseLong(content));
    }
}