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

济南建设网站公司哪个好如何保存个人网站

济南建设网站公司哪个好,如何保存个人网站,山东建设监理协会官方网站,网络平台推广宣传方案上一篇已经讲述了实现死信队列的rabbitMQ服务配置#xff0c;可以点击: RabbitMQ的延迟队列实现(笔记一) 目录 搭建一个新的springboot项目模仿订单延迟支付过期操作启动项目进行测试 搭建一个新的springboot项目 1.相关核心依赖如下 dependencygroupIdorg.…上一篇已经讲述了实现死信队列的rabbitMQ服务配置可以点击: RabbitMQ的延迟队列实现(笔记一) 目录 搭建一个新的springboot项目模仿订单延迟支付过期操作启动项目进行测试 搭建一个新的springboot项目 1.相关核心依赖如下 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependency!--mq依赖--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-amqp/artifactId/dependency!-- lombok 依赖 --dependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdoptionaltrue/optional/dependency2.配置文件如下 server:port: 8080spring:#MQ配置rabbitmq:host: ipport: 5673username: rootpassword: root123456783.目录结构 模仿订单延迟支付过期操作 1.创建OrderMqConstant.java设定常量代码如下 package com.example.aboutrabbit.constant; /*** description 订单队列常量* author lxh* time 2024/2/7 17:05*/ public interface OrderMqConstant {/***交换机*/String exchange order-event-exchange;/*** 队列*/String orderQueue order.delay.queue;/*** 路由*/String orderDelayRouting order.delay.routing; } 2.创建OrderDelayConfig.java配置绑定 package com.example.aboutrabbit.config;import com.example.aboutrabbit.constant.OrderMqConstant; import org.springframework.amqp.core.Binding; import org.springframework.amqp.core.BindingBuilder; import org.springframework.amqp.core.CustomExchange; import org.springframework.amqp.core.Queue; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;import java.util.HashMap; import java.util.Map;/*** author lxh* description 配置绑定* time 2024/2/7 17:15**/ Configuration public class OrderDelayConfig {/*** 延时队列交换机* 注意这里的交换机类型CustomExchange*/Beanpublic CustomExchange maliceDelayExchange() {MapString, Object args new HashMap();args.put(x-delayed-type, direct);// 属性参数 交换机名称 交换机类型 是否持久化 是否自动删除 配置参数return new CustomExchange(OrderMqConstant.exchange, x-delayed-message, true, false, args);}/*** 延时队列*/Beanpublic Queue maliceDelayQueue() {// 属性参数 队列名称 是否持久化return new Queue(OrderMqConstant.orderQueue, true);}/*** 给延时队列绑定交换机*/Beanpublic Binding maliceDelayBinding() {return BindingBuilder.bind(maliceDelayQueue()).to(maliceDelayExchange()).with(OrderMqConstant.orderDelayRouting).noargs();} } 3、创建 OrderMQReceiver.java监听过期的消息 package com.example.aboutrabbit.config;import com.example.aboutrabbit.constant.OrderMqConstant; import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.stereotype.Component;import java.text.SimpleDateFormat; import java.util.Date;/*** author lxh* description 接收过期订单* time 2024/2/7 17:21**/ Component Slf4j public class OrderMQReceiver {RabbitListener(queues OrderMqConstant.orderQueue)public void onDeadMessage(String infoId) {SimpleDateFormat sdf new SimpleDateFormat(yyyy-MM-dd HH:mm:ss);log.info(收到头框过期时间:{},消息是:{}, sdf.format(new Date()), infoId);} } 4.分别创建MQService.java和MQServiceImpl.java处理消息发送 package com.example.aboutrabbit.service; /*** description MQ发消息服务* author lxh* time 2024/2/7 17:26*/ public interface MQService {/*** 发送或加队列* param orderId 订单主键* param time 毫秒*/void sendOrderAddInfo(Long orderId, Integer time); } package com.example.aboutrabbit.service.impl;import com.example.aboutrabbit.constant.OrderMqConstant; import com.example.aboutrabbit.service.MQService; import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;import java.text.SimpleDateFormat; import java.util.Date;/*** author lxh* description MQ发消息服务实现* time 2024/2/7 17:26**/ Slf4j Service public class MQServiceImpl implements MQService {Autowiredprivate RabbitTemplate rabbitTemplate;/*** 发送或加队列* param orderId 订单主键* param time 毫秒*/Overridepublic void sendOrderAddInfo(Long orderId, Integer time) {SimpleDateFormat sdf new SimpleDateFormat(yyyy-MM-dd HH:mm:ss);log.info(过期队列添加|添加时间{}内容是{}过期毫秒数{},sdf.format(new Date()),orderId, time);rabbitTemplate.convertAndSend(OrderMqConstant.exchange, OrderMqConstant.orderDelayRouting,orderId,message - {message.getMessageProperties().setDelay(time);return message;});} } 5.创建控制层进行测试TestController.java package com.example.aboutrabbit.controller;import com.example.aboutrabbit.service.MQService; 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.RequestParam; import org.springframework.web.bind.annotation.RestController;/*** author lxh* description 测试* time 2024/2/7 17:36**/ RestController RequestMapping(/test) public class TestController {Autowiredprivate MQService mqService;GetMapping(/send)public String list(RequestParam Long orderId,RequestParam Integer fenTime) {//默认Integer time fenTime * 60 * 1000;mqService.sendOrderAddInfo(orderId, time);return success;} } 6.全部结构展示 启动项目进行测试 1.示例localhost:8080/test/send?orderId1fenTime1 订单id为1的延迟一分钟过期如下 2.查看日志
http://www.hkea.cn/news/14518378/

相关文章:

  • 网站制作免费外贸网站推广
  • 购买一个网站空间如何可以多个域名使用吗digging into wordpress pdf
  • 用c 做的网站怎么打开吗珠海市网站
  • 网站建设主机网页设计代码 link rel
  • 西柏坡门户网站建设规划书wordpress 看板
  • 简述一下网站的设计流程做网站那个公司好
  • 个人博客网站模板源码郑州seo排名工具
  • 不能打开建设银行网站怎么办网站做任务 炸金花
  • 住房和城乡建设部网站防排烟郑州网站制作电话
  • 做网站多久一个做外汇的网站叫熊猫什么的
  • 网站备案证书放到哪里凡科做网站类型应该做哪个
  • 织梦网站转移图书购物网站开发总结
  • wordpress可以做电影站西安软件开发培训机构
  • 沥林网站制作网站后台不能上传图片
  • 免费空间访客领取网站湛江网站制作费用
  • 英文企业网站带后台有数据库北京网站建设价格便宜
  • 河南建设网站官网微商城手机网站制作公司
  • 建设网站需要会什么免费wordpress主题
  • 建设个人网站用什么软件做网站的网页图片素材怎么找
  • 给别人做网站挣钱wordpress个人支付
  • 烟台电商网站开发江苏建安建设有限公司网站
  • 百度网盘官网网页版seo快速排名软件网址
  • 厦门网站建设建网站网页设计师使用的是什么的屏幕显示颜色模式
  • 购物网站设计开题报告宣传片广告公司
  • 大连企业网站模板建站做婚恋网站多少钱
  • 江西省住房和建设规划局局网站政协网站建设情况汇报
  • 高端的赣州网站建设新余网站设计
  • 视频网站亏钱为什么还要继续做中国科技成就排比句
  • 亚马逊海淘官网保定网站建设seo优化营销
  • 天津工程建设网官方网站wordpress类别图标