package com.qianwen.smartman.modules.notify.message.rocket.producer; import org.apache.rocketmq.client.producer.SendCallback; import org.apache.rocketmq.client.producer.SendResult; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.qianwen.core.notify.NotifyQueueProducer; import com.qianwen.core.notify.executor.NotifyExecutionContext; public class RocketNotifyQueueProducer implements NotifyQueueProducer { private static final Logger log = LoggerFactory.getLogger(RocketNotifyQueueProducer.class); private final RocketMQTemplate rocketMQTemplate; public RocketNotifyQueueProducer(final RocketMQTemplate rocketMQTemplate) { this.rocketMQTemplate = rocketMQTemplate; } public boolean syncSend(NotifyExecutionContext object) { return false; } public void asyncSend(final NotifyExecutionContext object) { this.rocketMQTemplate.asyncSend("notify-center-send-topic", object, new SendCallback() { // from class: org.springblade.modules.notify.message.rocket.producer.RocketNotifyQueueProducer.1 public void onSuccess(SendResult sendResult) { RocketNotifyQueueProducer.log.info("[RocketNotifyQueueProducer][发送消息:[{}] 发送成功,结果为:[{}]]", object.toString(), sendResult); } public void onException(Throwable throwable) { RocketNotifyQueueProducer.log.info("[RocketNotifyQueueProducer][发送消息:[{}] 发送异常]]", object.toString(), throwable); } }); } }