# testDemo **Repository Path**: osvue/test-demo ## Basic Information - **Project Name**: testDemo - **Description**: 测试用例 所有 测试用 - **Primary Language**: JavaScript - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-03-11 - **Last Updated**: 2021-04-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 依赖项目 ### 消息队列:rabbitMQ ### 缓存:redis ### 数据库: mysql ##### (后续会有ELK相关集成实例,Logback =>Logstash=>ElasticSearch=>Kibana) --- ### webSocket ```xml org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-websocket com.alibaba fastjson 1.2.47 ``` # 测试 hutool 工具 # 测试 webSocket # com/example/demo/test/ExcelCsv.java 导出 CSV 文件 # AsteriskPassword 黑科技, 查看密码 ****** (look) # event ApplicationContextEvent 事件 # springboot 集成RabbitMQ 延时消息 * 可将队列属性设置 ttl(TIME TO LIVE ) 过期时间,到达时间后,将消息转发至超时交换机,由超时交换机来进行投递,从而达到延迟队列 * 将消息属性设置为过期时间,也可以达到 **timeToLive** 效果,代码如下 ```java /** * 延迟时间不一致 * 测试消息过期的属性,SUCCESS */ void sendPerQueueTTL2() { for (int i = 1; i <= 3; i++) { long expiration = i * 1000; String time = 60000 + expiration + "";//延时时间,这样得到的值是毫秒级,rabbitMQ默认是毫秒 rabbitTemplate.convertAndSend(RabbitMqConfig.QUEUE_TTL_EXCHANGE_NAME, RabbitMqConfig.QUEUE_TTL_ROUTING_KEY2, "message" + LocalDateTime.now() + time, message -> { //设置消息持久化 //message.getMessageProperties().setDeliveryMode(MessageDeliveryMode.PERSISTENT); message.getMessageProperties().setExpiration(time); return message; }); } } ``` # # # # # # # ## 番外篇 - 2021/03/31 * 本月的最后一天,重构了整个项目结构,基于 [阿里云](https://start.aliyun.com/) 发布的快速启动框架(分层架构); * 未来将持续精进,更加的侧重于 [Spring Boot](https://spring.io/) 源码和设计模式的运用; * 敬请期待! - 2020/04/01 * 小tip ```xml org.springframework.cloud spring-cloud-commons-dependencies ${spring-cloud-commons.version} org.springframework.cloud spring-cloud-context ``` - 2021/04/08 * ChannelAwareMessageListener 另一种实现方式,[参考](https://www.freesion.com/article/4672584527/) ```java @Autowired private CachingConnectionFactory connectionFactory; @Bean public Queue productQueue() { return new Queue(RabbitMqConfig.QUEUE_TTL_NAME2); } // AmqpListener implements ChannelAwareMessageListener OverWrite Methods @Autowired AmqpListener productConsumerListener; @Bean(name = "simpleMessageListenerContainer") public SimpleMessageListenerContainer productMessageListenerContainerFactory() { SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(); listenerContainer.setConnectionFactory(connectionFactory); listenerContainer.setQueues(productQueue());//设置感兴趣的队列 listenerContainer.setMessageListener(productConsumerListener);//这里设置了消息的消费者 listenerContainer.setPrefetchCount(5);//设置预取消息的个数 return listenerContainer; } ```