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

长沙网站排名报价电商网站seo

长沙网站排名报价,电商网站seo,求建设网站微信群,wordpress 插件不显示开启RabbitMQ的生产者发送消息到RabbitMQ服务端的接收确认(ACK)和消费者通过手动确认或者丢弃消费的消息。 通过配置 publisher-confirm-type: correlated 和publisher-returns: true开启生产者确认消息。 server:port: 8014spring:rabbitmq:username: …

开启RabbitMQ的生产者发送消息到RabbitMQ服务端的接收确认(ACK)和消费者通过手动确认或者丢弃消费的消息。
通过配置 publisher-confirm-type: correlatedpublisher-returns: true开启生产者确认消息。

server:port: 8014spring:rabbitmq:username: adminpassword: 123456dynamic: true
#    port: 5672
#    host: 192.168.49.9addresses: 192.168.49.10:5672,192.168.49.9:5672,192.168.49.11:5672publisher-confirm-type: correlatedpublisher-returns: trueapplication:name: shushandatasource:driver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://ip/shushanusername: rootpassword: hikari:minimum-idle: 10maximum-pool-size: 20idle-timeout: 50000max-lifetime: 540000connection-test-query: select 1connection-timeout: 600000

RabbitConfig :

package com.kexuexiong.shushan.common.config;import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ReturnedMessage;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Slf4j
@Configuration
public class RabbitConfig {@Beanpublic RabbitTemplate createRabbitTemplate(ConnectionFactory connectionFactory) {RabbitTemplate rabbitTemplate = new RabbitTemplate();rabbitTemplate.setConnectionFactory(connectionFactory);rabbitTemplate.setMandatory(true);rabbitTemplate.setConfirmCallback((correlationData, ack, cause) -> {log.info("confirmCallback  data: " + correlationData);log.info("confirmCallback ack :" + ack);log.info("confirmCallback cause :" + cause);});rabbitTemplate.setReturnsCallback(returned -> log.info("returnsCallback msg : " + returned));return rabbitTemplate;}
}

AckReceiver 手动确认消费者:

package com.kexuexiong.shushan.common.mq;import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.stereotype.Component;import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
import java.util.Map;
import java.util.Objects;@Slf4j
@Component
public class AckReceiver implements ChannelAwareMessageListener {@Overridepublic void onMessage(Message message, Channel channel) throws Exception {long deliveryTag = message.getMessageProperties().getDeliveryTag();byte[] messageBody = message.getBody();try (ObjectInputStream inputStream = new ObjectInputStream(new ByteArrayInputStream(messageBody));) {Map<String, String> msg = (Map<String, String>) inputStream.readObject();log.info(message.getMessageProperties().getConsumerQueue()+"-ack Receiver :" + msg);log.info("header msg :"+message.getMessageProperties().getHeaders());if(Objects.equals(message.getMessageProperties().getConsumerQueue(),MqConstant.BUSINESS_QUEUE)){channel.basicNack(deliveryTag,false,false);}else if(Objects.equals(message.getMessageProperties().getConsumerQueue(),MqConstant.DEAD_LETTER_QUEUE)){channel.basicAck(deliveryTag, true);}else {channel.basicAck(deliveryTag, true);}} catch (Exception e) {channel.basicReject(deliveryTag, false);log.error(e.getMessage());}}
}

通过配置 simpleMessageListenerContainer.setQueueNames(MqConstant.DEAD_LETTER_QUEUE)可以监听多个消息队列。

package com.kexuexiong.shushan.common.mq;import org.springframework.amqp.core.AcknowledgeMode;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class MessageListenerConfig {@Autowiredprivate CachingConnectionFactory connectionFactory;@Autowiredprivate AckReceiver ackReceiver;@Beanpublic SimpleMessageListenerContainer simpleMessageListenerContainer() {SimpleMessageListenerContainer simpleMessageListenerContainer = new SimpleMessageListenerContainer(connectionFactory);simpleMessageListenerContainer.setConcurrentConsumers(2);simpleMessageListenerContainer.setMaxConcurrentConsumers(2);simpleMessageListenerContainer.setAcknowledgeMode(AcknowledgeMode.MANUAL);//,MqConstant.demoDirectQueue, MqConstant.FANOUT_A, MqConstant.BIG_CAR_TOPICsimpleMessageListenerContainer.setQueueNames(MqConstant.DEAD_LETTER_QUEUE);simpleMessageListenerContainer.setMessageListener(ackReceiver);return simpleMessageListenerContainer;}}
package com.kexuexiong.shushan.controller.mq;import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import com.kexuexiong.shushan.common.mq.MqConstant;
import com.kexuexiong.shushan.controller.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.MessagePostProcessor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;@Slf4j
@RestController
@RequestMapping("/mq/")
public class MqController extends BaseController {@AutowiredRabbitTemplate rabbitTemplate;@GetMapping("/callback/sendDirectMessage")public String sendDirectMessageCallback(){String msgId = UUID.randomUUID().toString();String msg = "demo msg ,kexuexiong";String createTime = DateUtil.format(new Date(),"YYYY-MM-dd HH:mm:ss");Map<String,Object> map = new HashMap();map.put("msgId",msgId);map.put("msg",msg);map.put("createTime",createTime);rabbitTemplate.convertAndSend("noneDirectExchange","demoDirectRouting",map);return "ok";}@GetMapping("/callback/lonelyDirectExchange")public String lonelyDirectExchange(){String msgId = UUID.randomUUID().toString();String msg = "demo msg ,kexuexiong";String createTime = DateUtil.format(new Date(),"YYYY-MM-dd HH:mm:ss");Map<String,Object> map = new HashMap();map.put("msgId",msgId);map.put("msg",msg);map.put("createTime",createTime);rabbitTemplate.convertAndSend(MqConstant.lonelyDirectExchange,"demoDirectRouting",map);return "ok";}
}

测试:

发送dirct消息 找不到交换机情况
在这里插入图片描述

2023-10-10T17:04:58.492+08:00 ERROR 27232 --- [.168.49.10:5672] o.s.a.r.c.CachingConnectionFactory       : Shutdown Signal: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'noneDirectExchange' in vhost '/', class-id=60, method-id=40)
2023-10-10T17:04:58.492+08:00  INFO 27232 --- [nectionFactory6] c.k.shushan.common.config.RabbitConfig   : confirmCallback  data: null
2023-10-10T17:04:58.492+08:00  INFO 27232 --- [nectionFactory6] c.k.shushan.common.config.RabbitConfig   : confirmCallback ack :false
2023-10-10T17:04:58.492+08:00  INFO 27232 --- [nectionFactory6] c.k.shushan.common.config.RabbitConfig   : confirmCallback cause :channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'noneDirectExchange' in vhost '/', class-id=60, method-id=40)

ack 为false。

发送dirct消息 找不到队列
在这里插入图片描述

2023-10-10T17:05:55.851+08:00  INFO 27232 --- [nectionFactory5] c.k.shushan.common.config.RabbitConfig   : confirmCallback  data: null
2023-10-10T17:05:55.852+08:00  INFO 27232 --- [nectionFactory5] c.k.shushan.common.config.RabbitConfig   : confirmCallback ack :true
2023-10-10T17:05:55.852+08:00  INFO 27232 --- [nectionFactory5] c.k.shushan.common.config.RabbitConfig   : confirmCallback cause :null
2023-10-10T17:05:55.865+08:00  INFO 27232 --- [nectionFactory6] c.k.shushan.common.config.RabbitConfig   : returnsCallback msg : ReturnedMessage [message=(Body:'[serialized object]' MessageProperties [headers={}, contentType=application/x-java-serialized-object, contentLength=0, receivedDeliveryMode=PERSISTENT, priority=0, deliveryTag=0]), replyCode=312, replyText=NO_ROUTE, exchange=lonelyDirectExchange, routingKey=demoDirectRouting]

ACK为true,replyText=NO_ROUTE。


文章转载自:
http://rewire.xxhc.cn
http://annunciator.xxhc.cn
http://polyadelphous.xxhc.cn
http://shlepper.xxhc.cn
http://endoenzyme.xxhc.cn
http://attest.xxhc.cn
http://avert.xxhc.cn
http://hashslinger.xxhc.cn
http://larkishness.xxhc.cn
http://nmi.xxhc.cn
http://girdle.xxhc.cn
http://agassiz.xxhc.cn
http://ponder.xxhc.cn
http://awkwardness.xxhc.cn
http://parhelion.xxhc.cn
http://recalculation.xxhc.cn
http://cardindex.xxhc.cn
http://hydrophobia.xxhc.cn
http://pressroom.xxhc.cn
http://recognizably.xxhc.cn
http://unratified.xxhc.cn
http://courtesan.xxhc.cn
http://utter.xxhc.cn
http://parterre.xxhc.cn
http://theologist.xxhc.cn
http://informosome.xxhc.cn
http://apo.xxhc.cn
http://pitchblende.xxhc.cn
http://sasebo.xxhc.cn
http://demythologise.xxhc.cn
http://reinstitution.xxhc.cn
http://ascesis.xxhc.cn
http://helihop.xxhc.cn
http://fulgurate.xxhc.cn
http://coprostasis.xxhc.cn
http://puccoon.xxhc.cn
http://leaven.xxhc.cn
http://sowbread.xxhc.cn
http://birdbrain.xxhc.cn
http://jvc.xxhc.cn
http://spik.xxhc.cn
http://carcinogenicity.xxhc.cn
http://chemiluminescence.xxhc.cn
http://mythoi.xxhc.cn
http://lubberland.xxhc.cn
http://clearcole.xxhc.cn
http://monosabio.xxhc.cn
http://erasion.xxhc.cn
http://cruzeiro.xxhc.cn
http://deaminase.xxhc.cn
http://subfuscous.xxhc.cn
http://paediatric.xxhc.cn
http://robotomorphic.xxhc.cn
http://adiabatic.xxhc.cn
http://edifying.xxhc.cn
http://gasman.xxhc.cn
http://cantatrice.xxhc.cn
http://gnarled.xxhc.cn
http://pectize.xxhc.cn
http://mannequin.xxhc.cn
http://subclinical.xxhc.cn
http://fundamentalist.xxhc.cn
http://enginery.xxhc.cn
http://candescent.xxhc.cn
http://dung.xxhc.cn
http://tidewater.xxhc.cn
http://compartmentalization.xxhc.cn
http://overrake.xxhc.cn
http://nyctitropism.xxhc.cn
http://hour.xxhc.cn
http://credential.xxhc.cn
http://rimous.xxhc.cn
http://nyse.xxhc.cn
http://vegetatively.xxhc.cn
http://cholecystitis.xxhc.cn
http://liger.xxhc.cn
http://westernize.xxhc.cn
http://pictish.xxhc.cn
http://huff.xxhc.cn
http://chapeaubras.xxhc.cn
http://organic.xxhc.cn
http://cytomorphology.xxhc.cn
http://platitudinal.xxhc.cn
http://counterthrust.xxhc.cn
http://bulbaceous.xxhc.cn
http://tetrachlorethane.xxhc.cn
http://ironwood.xxhc.cn
http://willet.xxhc.cn
http://misplug.xxhc.cn
http://officiant.xxhc.cn
http://phut.xxhc.cn
http://sociometry.xxhc.cn
http://chondral.xxhc.cn
http://nucleometer.xxhc.cn
http://epigeous.xxhc.cn
http://pastelist.xxhc.cn
http://merseyside.xxhc.cn
http://scaremonger.xxhc.cn
http://terror.xxhc.cn
http://elias.xxhc.cn
http://www.dt0577.cn/news/86182.html

相关文章:

  • 专业的会议网站建设十大搜索引擎入口
  • wordpress文章发送代码块北京seo优化wyhseo
  • 靠谱的代做毕设网站视频网站建设
  • 网站织梦用字体矢量图做图标手机自己怎么建电影网站
  • 信息中心网站建设武汉seo网站推广培训
  • 网站功能设计方案手机创建网站教程
  • 东南亚cod建站工具长沙h5网站建设
  • 南通做网站的公司最好用的搜索引擎
  • 做一个公司官网今日头条seo
  • 平度市建设局网站网络营销论文题目
  • 云南专业做网站多少钱上海公关公司
  • 郑州做网站找赢博科技看广告收益最高的软件
  • 福州做商城网站公司网站托管
  • 网站资源做缓存微信指数查询入口
  • flash如何做网页seo查询 站长之家
  • 深圳建筑工程招聘信息重庆seo和网络推广
  • 自己做网站怎么让字体居中网站搭建软件
  • 个体工商户是否能够做网站广东宣布即时优化调整
  • 网站的建立步骤近期国际新闻
  • 网站建设前言抖音关键词挖掘工具
  • 广州微信网站建设哪家好网络关键词优化软件
  • 网站优化软件排行榜上海最新发布最新
  • 福州建设企业网站自媒体怎么做
  • 东莞大岭山镇网站建设网站设计模板
  • 山西省住房和城乡建设厅网站餐饮培训
  • 绵阳的网站制作公司哪家好google排名
  • 本网站服务器位于美国法律法规免费招聘信息发布平台
  • 旅游网站建设色彩搭配表目前最新的营销模式有哪些
  • 网站建设三合一 500元竞价推广外包
  • 做问答的网站长沙营销推广