You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.1 KiB
35 lines
1.1 KiB
package com.example.demo.RabbitMQ;
|
|
|
|
import com.example.demo.config.RabbitMQConfig;
|
|
import com.example.demo.domain.DTO.MessageDTO;
|
|
import com.example.demo.domain.DTO.OperationLogDTO;
|
|
import com.example.demo.domain.entity.OperationLog;
|
|
import com.example.demo.domain.vo.cash.CashCollectionMessage;
|
|
import com.example.demo.domain.vo.coin.Messages;
|
|
import com.example.demo.mapper.coin.OperationLogMapper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
/**
|
|
* 收款流程消息消费者
|
|
* 监听收款流程中各个状态变更的消息队列
|
|
*/
|
|
@Component
|
|
@Slf4j
|
|
public class CashCollectionConsumer {
|
|
@Autowired
|
|
private OperationLogMapper operationLogMapper;
|
|
|
|
@RabbitListener(queues = RabbitMQConfig.CASH_COLLECTION_QUEUE)
|
|
public void consumeLog(Messages messages) {
|
|
try {
|
|
operationLogMapper.insertMessage(messages);
|
|
|
|
} catch (Exception e) {
|
|
log.error("持久化日志失败", e);
|
|
// 可以重试或记录到文件
|
|
}
|
|
}
|
|
}
|