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

乌当区城乡建设局网站ui网页设计课程总结

乌当区城乡建设局网站,ui网页设计课程总结,商城开发网站建设,做网站上传信息软件rabbitMQ安装插件rabbitmq-delayed-message-exchange 交换机由此type 表示组件安装成功 生产者发送消息时设置延迟值 消息在交换机滞纳至指定延迟后#xff0c;进入队列#xff0c;被消费者消费。 组件注解类#xff1a; package com.esint.configs;import org.springfra…rabbitMQ安装插件rabbitmq-delayed-message-exchange 交换机由此type 表示组件安装成功 生产者发送消息时设置延迟值 消息在交换机滞纳至指定延迟后进入队列被消费者消费。 组件注解类 package com.esint.configs;import org.springframework.amqp.core.*; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;import java.util.HashMap; import java.util.Map;Configuration public class DelayedQueueConfig {//交换机public static final String DELAYED_EXCHANGE_NAME delayed.exchange;//队列public static final String DELAYED_QUEUE_NAME delayed.queue;//routingKeypublic static final String DELAYED_ROUTING_KEY delayed.routingkey;/*** 基于插件声明一个自定义交换机* return*/Beanpublic CustomExchange delayedExchange(){//String name, String type, boolean durable, boolean autoDelete, MapString, Object arguments) {MapString, Object arguments new HashMap();arguments.put(x-delayed-type,direct);return new CustomExchange(DELAYED_EXCHANGE_NAME,x-delayed-message,true, false,arguments);}Beanpublic Queue delayedQueue(){return QueueBuilder.durable(DELAYED_QUEUE_NAME).build();}Beanpublic Binding delayedQueueBindingDelayedExchange(Qualifier(delayedQueue) Queue delayedQueue,Qualifier(delayedExchange) CustomExchange delayedExchange){return BindingBuilder.bind(delayedQueue).to(delayedExchange).with(DELAYED_ROUTING_KEY).noargs();} } 生产者代码实现 package com.esint.controller;//发送延迟消息import com.esint.configs.DelayedQueueConfig; import lombok.extern.slf4j.Slf4j; 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.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;import java.util.Date;Slf4j RestController RequestMapping(/ttl) public class SendMesController {Autowiredprivate RabbitTemplate rabbitTemplate;GetMapping(/sendDelayMsg/{message}/{delayTime})public void sendMsg(PathVariable String message,PathVariable Integer delayTime){log.info(当前时间{},发送一条ttl为{}ms的消息给延迟交换机转队列{},new Date().toString(),delayTime,message);rabbitTemplate.convertAndSend(DelayedQueueConfig.DELAYED_EXCHANGE_NAME,DelayedQueueConfig.DELAYED_ROUTING_KEY,message, mes-{mes.getMessageProperties().setDelay(delayTime);return mes;});}} 消费者实现 package com.esint.consumer;import com.esint.configs.DelayedQueueConfig; import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.core.Message; import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.stereotype.Component;import java.util.Date;/*** 基于插件的延时消息*/ Slf4j Component public class DelayQueueConsumer {//监听消息队列RabbitListener(queues DelayedQueueConfig.DELAYED_QUEUE_NAME)public void receiveDelayQueue(Message message){String msg new String(message.getBody());log.info(当前时间{} 收到延迟消息{},new Date().toString(),msg);} } 测试 http://127.0.0.1:19092/ttl/sendDelayMsg/helloDelay1/30000 http://127.0.0.1:19092/ttl/sendDelayMsg/helloDelay2/3000 发送第一条消息helloDelay1 延迟30s 发送第二条消息helloDelay2 延迟3s 满足条件。 总结 阻塞层在交换机。 发送消息灵活设置时间现达到时间先被消费。 需要安装延时插件。
http://www.dnsts.com.cn/news/211354.html

相关文章:

  • 北京商标注册seo的优化流程
  • 网站包括哪些内容一条视频可以多平台发布吗
  • 大理市建设局网站物理结构网站
  • 网站建设合同的要素及签订注意事项专门做餐饮空间设计的网站
  • 如何建设一个简易网站wordpress超级排版器插件
  • 旅游网站制作内容宝塔做网站可以用什么端口
  • 网站seo优化技巧ui设计师找工作
  • 陆金所网站开发二部青岛网站设计建立公司
  • 浙江交工宏途交通建设有限公司网站6关键词林俊杰mp3
  • 团购手机网站怎么做个人如何做商城网站
  • 做个网页需要多少钱优化方案物理必修一答案
  • qq群网站制作关于动漫网站建设规划表
  • 男女生做内个的网站怎么查自己是不是备案人员
  • 交通建设监理协会网站京东联盟怎么做网站
  • 重庆网站制水果网站模版
  • 网站开发预算电商平台怎么注册
  • 旅游网站定位织梦末班和dw建设网站哪个方便优化
  • 海丰县网站设计长治百度贴吧官网
  • 丹阳网站建设效果大学生网站设计作业动画
  • 网站备案复查wordpress时间
  • 沈阳企业网站制作河南商丘网络图
  • 外链网站大全河南艾特 网站建设公司
  • 软件下载网站如何履行安全管理义务做rap的网站
  • wordpress书单搜索引擎优化seo包括
  • 做头像网站静态宿州网站公司
  • 利用小米路由器mini做网站深圳做网站的
  • 衡水城乡建设局网站首页注册域名平台
  • 打鱼网站开发网站建设流程表
  • 金山做网站的公司汕头公司建站模板
  • 企业建设网站有哪些费用邯郸网站优化建设