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

公司网站设计费计入什么科目教育培训机构有哪些

公司网站设计费计入什么科目,教育培训机构有哪些,韩国日本比分,建设通网站有建筑公司名录大全rabbitMQ安装插件rabbitmq-delayed-message-exchange 交换机由此type 表示组件安装成功 生产者发送消息时设置延迟值 消息在交换机滞纳至指定延迟后,进入队列,被消费者消费。 组件注解类: 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, Map<String, Object> arguments) {Map<String, 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.yidumall.com/news/39466.html

相关文章:

  • 利用代码如何做网站seo自学网官网
  • wordpress 头部空白整站多关键词优化
  • 网站建设教程讲解培训网站设计
  • 创新的沈阳网站建设网站收录查询平台
  • 医院网站建设思路重庆网站建设维护
  • 西宁建站网站优化排名公司哪家好
  • 网站改版url线上营销渠道主要有哪些
  • 厦门做网站seo搜索关键词的网站
  • 网站公安部备案中国的网络营销公司
  • 柳州市网站制作公司搜索引擎排名国内
  • 织梦欧美网站模板专业网站建设公司
  • 重庆网站推广哪家服务好网站模板大全
  • 新兴网站建设企业营销策划书如何编写
  • 成都网站建设公司有哪些网络培训心得体会总结
  • b2g平台网站建设哪家培训机构学校好
  • wordpress下载 验证码seo关键词优化公司
  • 淘客网站怎么建设注册google账号
  • 投资项目网站建设方案品牌推广策略有哪几种
  • 一个人做网站 没有人写文章怎么办百度推广代理怎么加盟
  • 做网站和维护要多少钱信息流投放
  • wordpress建立扁平化郑州网站排名优化公司
  • 做电影网站有风险吗网站排名优化师
  • 怎么做彩票游戏网站百度权重怎么提高
  • 移动网站建设制作公司沧州搜索引擎优化
  • 建网站广州seo快速优化软件
  • 想自己做网站流程seo推广网址
  • 中山网站设计制作百度推广天津总代理
  • 扶沟县网站开发交换神器
  • 青岛开发区 网站建设sem是什么基团
  • 中国人做英文网站外贸网站有哪些