mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-20 18:15:56 +08:00
Pre Merge pull request !386 from 月夜/dev
This commit is contained in:
commit
7f38e631fa
@ -28,6 +28,9 @@ import java.util.concurrent.TimeUnit;
|
||||
@RequestMapping("/demo/queue/delayed")
|
||||
public class DelayedQueueController {
|
||||
|
||||
//注入线程池-需要在application.yml中将thread-pool.enabled设置为true
|
||||
private final ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
||||
|
||||
/**
|
||||
* 订阅队列
|
||||
*
|
||||
@ -40,6 +43,13 @@ public class DelayedQueueController {
|
||||
QueueUtils.subscribeBlockingQueue(queueName, (String orderNum) -> {
|
||||
// 观察接收时间
|
||||
log.info("通道: {}, 收到数据: {}", queueName, orderNum);
|
||||
|
||||
//业务代码
|
||||
//注:如业务代码部分使用到了redis相关操作,需要将业务逻辑异步,否则将会报错:Sync methods can't be invoked from async/rx/reactive listeners
|
||||
//示例
|
||||
threadPoolTaskExecutor.execute(() -> {
|
||||
String str = RedisUtils.getCacheObject("test");
|
||||
});
|
||||
});
|
||||
return R.ok("操作成功");
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user