| | |
| | | package org.dromara.demo.controller.queue; |
| | | |
| | | import cn.dev33.satoken.annotation.SaIgnore; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.redis.utils.QueueUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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; |
| | | |
| | | import java.util.concurrent.TimeUnit; |
| | |
| | | * @author Lion Li |
| | | * @version 3.6.0 |
| | | */ |
| | | @SaIgnore |
| | | @Slf4j |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | |
| | | QueueUtils.subscribeBlockingQueue(queueName, (String orderNum) -> { |
| | | // 观察接收时间 |
| | | log.info("通道: {}, 收到数据: {}", queueName, orderNum); |
| | | |
| | | }); |
| | | return R.ok("操作成功"); |
| | | } |
| | |
| | | * |
| | | * @param queueName 队列名 |
| | | * @param orderNum 订单号 |
| | | * @param time 延迟时间(秒) |
| | | // * @param time 延迟时间(秒) |
| | | */ |
| | | @GetMapping("/add") |
| | | public R<Void> add(String queueName, String orderNum, Long time) { |
| | | QueueUtils.addDelayedQueueObject(queueName, orderNum, time, TimeUnit.SECONDS); |
| | | public R<Void> add(@RequestParam("queueName") String queueName, @RequestParam("orderNum")String orderNum) { |
| | | QueueUtils.addDelayedQueueObject(queueName, orderNum, 5, TimeUnit.SECONDS); |
| | | // 观察发送时间 |
| | | log.info("通道: {} , 发送数据: {}", queueName, orderNum); |
| | | return R.ok("操作成功"); |