123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- //package com.gxzc.zen.mq.publisher
- //
- //import org.slf4j.LoggerFactory
- //import org.springframework.amqp.core.Message
- //import org.springframework.amqp.rabbit.core.RabbitTemplate
- //import org.springframework.amqp.rabbit.support.CorrelationData
- //import org.springframework.beans.factory.annotation.Autowired
- //import org.springframework.stereotype.Component
- //import javax.annotation.PostConstruct
- //
- //
- ///**
- // *
- // * @author NorthLan
- // * @date 2018/1/31
- // * @url https://noahlan.com
- // */
- //@Component
- //class Sender : RabbitTemplate.ConfirmCallback, RabbitTemplate.ReturnCallback {
- // companion object {
- // val logger = LoggerFactory.getLogger(Sender::class.java)
- // }
- //
- // @Autowired
- // private lateinit var rabbitTemplate: RabbitTemplate
- //
- // @PostConstruct
- // fun init() {
- // rabbitTemplate.setConfirmCallback(this)
- // rabbitTemplate.setReturnCallback(this)
- // }
- //
- // override fun returnedMessage(message: Message, replyCode: Int, replyText: String?, exchange: String?, routingKey: String?) {
- // logger.info(message.messageProperties.correlationIdString + " 发送失败")
- // }
- //
- // override fun confirm(correlationData: CorrelationData?, ack: Boolean, cause: String?) {
- // if (ack) {
- // logger.info("消息发送成功:" + correlationData)
- // } else {
- // logger.info("消息发送失败:" + cause)
- // }
- // }
- //
- // fun send(msg: String) {
- // val correlationData = CorrelationData("2333")
- // logger.info("发消息: {}", msg)
- // val response = rabbitTemplate.convertSendAndReceive("te", "key.1", msg, correlationData).toString()
- // logger.info("回执: {}", response)
- // }
- //}
|