|
|
|
@ -2,13 +2,17 @@ package com.mashibing.search.mq;
|
|
|
|
|
|
|
|
|
|
import com.mashibing.common.constant.RabbitMQConstant;
|
|
|
|
|
import com.mashibing.common.pojo.StandardSubmit;
|
|
|
|
|
import com.mashibing.common.utils.JsonUtil;
|
|
|
|
|
import com.mashibing.search.service.SearchService;
|
|
|
|
|
import com.rabbitmq.client.Channel;
|
|
|
|
|
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.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author heqijun
|
|
|
|
@ -21,10 +25,21 @@ import java.io.IOException;
|
|
|
|
|
@Component
|
|
|
|
|
public class SmsWriteLogListener {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
SearchService searchService;
|
|
|
|
|
|
|
|
|
|
private final String INDEX = "sms_submit_log_";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RabbitListener(queues = {RabbitMQConstant.SMS_WRITE_LOG})
|
|
|
|
|
public void process(StandardSubmit submit, Channel channel, Message message) throws IOException {
|
|
|
|
|
|
|
|
|
|
log.info("接收到存储日志的信息,submit={}", submit);
|
|
|
|
|
String sequenceId = submit.getSequenceId().toString();
|
|
|
|
|
String json = JsonUtil.obj2Json(submit);
|
|
|
|
|
String year = LocalDateTime.now().getYear() + "";
|
|
|
|
|
searchService.index(INDEX + year, sequenceId, json);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//手动ack
|
|
|
|
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
|
|