package cc.mrbird.febs.rabbit.producer; import cc.mrbird.febs.rabbit.QueueEnum; import cc.mrbird.febs.rabbit.RabbitMqConfig; import cn.hutool.core.util.IdUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.rabbit.connection.CorrelationData; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.UUID; /** * @author wzy * @date 2020-05-25 **/ @Slf4j @Component public class UsdtUpdateProducer implements RabbitTemplate.ConfirmCallback { private RabbitTemplate rabbitTemplate; @Autowired public UsdtUpdateProducer(RabbitTemplate rabbitTemplate) { this.rabbitTemplate = rabbitTemplate; rabbitTemplate.setConfirmCallback(this); } public void sendMemberCoinInside(Long withdrawId) { log.info("发送用户内部转账的消息:{}", withdrawId); CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString()); rabbitTemplate.convertAndSend(RabbitMqConfig.MEMBER_COIN_INSIDE_EXCHANGE, RabbitMqConfig.MEMBER_COIN_INSIDE__ROUTE_KEY, withdrawId, correlationData); } public void sendOnHookEnd(Long orderId) { log.info("发送用户结束挂机的消息:{}", orderId); CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString()); rabbitTemplate.convertAndSend(RabbitMqConfig.END_ON_HOOK_EXCHANGE, RabbitMqConfig.END_ON_HOOK_ROUTE_KEY, orderId, correlationData); } public void sendMsg(String content) { CorrelationData correlationData = new CorrelationData(IdUtil.simpleUUID()); rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_USDT_UPDATE, RabbitMqConfig.ROUTING_KEY_USDT_UPDATE, content, correlationData); } public void sendAddressMsg(String content) { CorrelationData correlationData = new CorrelationData(IdUtil.simpleUUID()); rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_USDT_ADDRESS, RabbitMqConfig.ROUTING_KEY_USDT_ADDRESS, content, correlationData); } public void sendTrc20BlockMsg(String content) { CorrelationData correlationData = new CorrelationData(IdUtil.simpleUUID()); rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_ONE, RabbitMqConfig.ROUTING_TRC20_BLOCK, content, correlationData); } @Override public void confirm(CorrelationData correlationData, boolean ack, String cause) { // log.info("#----->{}#", correlationData); if (ack) { // log.info("success"); } else { log.info("--->{}", cause); } } }