Sender.kt 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //package com.gxzc.zen.mq.publisher
  2. //
  3. //import org.slf4j.LoggerFactory
  4. //import org.springframework.amqp.core.Message
  5. //import org.springframework.amqp.rabbit.core.RabbitTemplate
  6. //import org.springframework.amqp.rabbit.support.CorrelationData
  7. //import org.springframework.beans.factory.annotation.Autowired
  8. //import org.springframework.stereotype.Component
  9. //import javax.annotation.PostConstruct
  10. //
  11. //
  12. ///**
  13. // *
  14. // * @author NorthLan
  15. // * @date 2018/1/31
  16. // * @url https://noahlan.com
  17. // */
  18. //@Component
  19. //class Sender : RabbitTemplate.ConfirmCallback, RabbitTemplate.ReturnCallback {
  20. // companion object {
  21. // val logger = LoggerFactory.getLogger(Sender::class.java)
  22. // }
  23. //
  24. // @Autowired
  25. // private lateinit var rabbitTemplate: RabbitTemplate
  26. //
  27. // @PostConstruct
  28. // fun init() {
  29. // rabbitTemplate.setConfirmCallback(this)
  30. // rabbitTemplate.setReturnCallback(this)
  31. // }
  32. //
  33. // override fun returnedMessage(message: Message, replyCode: Int, replyText: String?, exchange: String?, routingKey: String?) {
  34. // logger.info(message.messageProperties.correlationIdString + " 发送失败")
  35. // }
  36. //
  37. // override fun confirm(correlationData: CorrelationData?, ack: Boolean, cause: String?) {
  38. // if (ack) {
  39. // logger.info("消息发送成功:" + correlationData)
  40. // } else {
  41. // logger.info("消息发送失败:" + cause)
  42. // }
  43. // }
  44. //
  45. // fun send(msg: String) {
  46. // val correlationData = CorrelationData("2333")
  47. // logger.info("发消息: {}", msg)
  48. // val response = rabbitTemplate.convertSendAndReceive("te", "key.1", msg, correlationData).toString()
  49. // logger.info("回执: {}", response)
  50. // }
  51. //}