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

  1. package com.example.demo.RabbitMQ;
  2. import com.example.demo.config.RabbitMQConfig;
  3. import com.example.demo.domain.DTO.MessageDTO;
  4. import com.example.demo.domain.DTO.OperationLogDTO;
  5. import com.example.demo.domain.entity.OperationLog;
  6. import com.example.demo.domain.vo.cash.CashCollectionMessage;
  7. import com.example.demo.domain.vo.coin.Messages;
  8. import com.example.demo.mapper.coin.OperationLogMapper;
  9. import lombok.extern.slf4j.Slf4j;
  10. import org.springframework.amqp.rabbit.annotation.RabbitListener;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.stereotype.Component;
  13. /**
  14. * 收款流程消息消费者
  15. * 监听收款流程中各个状态变更的消息队列
  16. */
  17. @Component
  18. @Slf4j
  19. public class CashCollectionConsumer {
  20. @Autowired
  21. private OperationLogMapper operationLogMapper;
  22. @RabbitListener(queues = RabbitMQConfig.CASH_COLLECTION_QUEUE)
  23. public void consumeLog(Messages messages) {
  24. try {
  25. operationLogMapper.insertMessage(messages);
  26. } catch (Exception e) {
  27. log.error("持久化日志失败", e);
  28. // 可以重试或记录到文件
  29. }
  30. }
  31. }