当前位置: 首页 > news >正文

陕西省门户网站建设政策seo快排软件

陕西省门户网站建设政策,seo快排软件,做网站哪个公司比较好,建设银行官方网站客户端回调函数confirm中的correlationDatanull // 实现confirm回调,发送到和没发送到exchange,都触发 Override public void confirm(CorrelationData correlationData, boolean ack, String cause) {// 参数说明:// correlationData: 相关数据,可以在发送消息时,进行设置该参数// …

回调函数confirm中的correlationData=null

// 实现confirm回调,发送到和没发送到exchange,都触发
@Override
public void confirm(CorrelationData correlationData, boolean ack, String cause) {// 参数说明:// correlationData: 相关数据,可以在发送消息时,进行设置该参数// ack: 结果// cause: 原因if (ack) {log.info("【ConfirmCallback】消息已经送达Exchange,ack已发");} else {ReturnedMessage message = correlationData.getReturned();if (message != null) {String msgData = new String(message.getMessage().getBody());log.error("消息发送到 exchange {} 失败,原因: {},id: {}, routingKey: {},body: {}", message.getExchange(), cause, correlationData.getId(), message.getRoutingKey(), msgData);} else {log.error("消息发送 exchange 失败,原因: {},id: {}", correlationData.getId(),cause);}}
}

解决办法

在convertAndSend方法中传入correlationData数据

@SpringBootTest
class RabbitmqDemoApplicationTests {@Testvoid contextLoads() {// 模拟消息BattleSubmitMqVo msg = new BattleSubmitMqVo().setUserId(1L).setRoomId("123").setTimes(300L);// 工具类发送消息到mqMqUtil.sendMsgToMq(RabbitConfig.BATTLE_PAPER_EXCHANGE,RabbitConfig.BATTLE_PAPER_ROUTING_KEY, msg);}}

工具类

package com.example.rabbitmqdemo.util;import cn.hutool.json.JSONUtil;
import com.sun.istack.internal.NotNull;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessagePostProcessor;
import org.springframework.amqp.core.ReturnedMessage;
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 javax.annotation.PostConstruct;/*** desc:** @author qts* @date 2023/11/3 0003*/
@Component
public class MqUtil {private static RabbitTemplate rabbitTemplate;@Autowiredprivate RabbitTemplate rabbitTemplate2;@PostConstructpublic void init(){rabbitTemplate = rabbitTemplate2;}/*** 发送消息并* 添加 CorrelationData数据* @param exchange* @param routingKey* @param msg*/public static void sendMsgToMq(String exchange, String routingKey, Object msg){CorrelationData correlationData = new CorrelationData();correlationData.setReturned(new ReturnedMessage(new Message(JSONUtil.toJsonStr(msg).getBytes()),1,"1",exchange,routingKey));rabbitTemplate.convertAndSend(exchange,routingKey,msg,correlationData);}/*** 发送消息* 添加 CorrelationData数据, 消息后处理回调* @param exchange* @param routingKey* @param msg* @param messagePostProcessor 消息后处理回调*/public static void sendMsgToMq(String exchange, String routingKey, Object msg,MessagePostProcessor messagePostProcessor){CorrelationData correlationData = new CorrelationData();correlationData.setReturned(new ReturnedMessage(new Message(JSONUtil.toJsonStr(msg).getBytes()),1,"1",exchange,routingKey));rabbitTemplate.convertAndSend(exchange,routingKey,msg,messagePostProcessor,correlationData);}
}

效果

得到了值
在这里插入图片描述

springboot集成rabbitmq

http://www.hkea.cn/news/390373/

相关文章:

  • 余江区建设局网站百度搜索引擎优化的方法
  • 做网站用c 还是java万网域名注册教程
  • 青岛做网站那家好专业的网站优化公司排名
  • 网站如何做淘宝推广seo服务 收费
  • 学完js了可以做哪些网站营业推广的形式包括
  • 网站会员系统怎么做模版seo是指什么职位
  • 上海集团网站制作新闻 近期大事件
  • 商城网站验收标准seo关键词排名优化怎样收费
  • 睢宁做网站公司珠海百度关键字优化
  • 临安市住房和建设局网站伊春seo
  • 天津百度做网站多少钱游戏代理平台哪个好
  • b2b模式的网站google网站
  • 做优化网站哪个公司好十大营销策略
  • 软件商店app苏州网站关键词优化推广
  • wordpress添加日历首页优化公司
  • 日本可以自己做网站吗查询网站服务器
  • 做网站维护的人叫啥友情链接交换工具
  • 云南网站定制真正永久免费的建站系统有哪些
  • 温州做网站技术员沧州做网络推广的平台
  • wordpress media上海排名优化seobwyseo
  • 深圳网站建设科技有限公司注册一个网站
  • 网站设计改版seo关键词优化推广价格
  • 做网站什么主题比较好上海网站seo诊断
  • 设计苹果手机的网站病毒什么时候才能消失
  • 国外做化工产品的网站自媒体发布平台
  • 怎么做资源类网站百度搜索热度排名
  • 大片网站建设seo关键词排名优化评价
  • 网络营销推广课程培训苏州seo门户网
  • 做盗版影视网站如何给公司网站做推广
  • 做网站付费流程郑州seo技术