From 23182f2c951df5fa55e70e30ff70ddaf91199a2e Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期四, 05 二月 2026 15:57:58 +0800
Subject: [PATCH] 1
---
zy-acs-hex/src/main/java/com/zy/acs/hex/config/RabbitConfig.java | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/zy-acs-hex/src/main/java/com/zy/acs/hex/config/RabbitConfig.java b/zy-acs-hex/src/main/java/com/zy/acs/hex/config/RabbitConfig.java
new file mode 100644
index 0000000..486003d
--- /dev/null
+++ b/zy-acs-hex/src/main/java/com/zy/acs/hex/config/RabbitConfig.java
@@ -0,0 +1,31 @@
+package com.zy.acs.hex.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Slf4j
+@Configuration
+public class RabbitConfig {
+
+ @Bean
+ public RabbitTemplate rabbitTemplate(CachingConnectionFactory connectionFactory) {
+ RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
+ rabbitTemplate.setConfirmCallback((correlationData, ack, cause) -> {
+ if (ack) {
+ log.info("娑堟伅鎴愬姛鍙戦�佸埌Exchange");
+ } else {
+ log.info("娑堟伅鍙戦�佸け璐ワ細" + cause);
+ }
+ });
+ // 涔熷彲浠ヨ缃繑鍥炵被鍨嬩负mandatory锛岃繖鏍峰綋娑堟伅鏃犳硶璺敱鍒颁换浣曢槦鍒楁椂锛屼細杩斿洖缁欑敓浜ц�呬竴涓狟asic.Return銆�
+ rabbitTemplate.setMandatory(true);
+ rabbitTemplate.setReturnCallback((message, replyCode, replyText, exchange, routingKey) -> {
+ log.info("娑堟伅鏃犳硶璺敱鍒伴槦鍒�: " + replyText);
+ });
+ return rabbitTemplate;
+ }
+
+}
--
Gitblit v1.9.1