| | |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.utils.redis.QueueUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | * @version 3.6.0 |
| | | */ |
| | | @Slf4j |
| | | @Api(value = "有界队列 演示案例", tags = {"有界队列"}) |
| | | @Tag(name ="有界队列 演示案例", description = "有界队列") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/queue/bounded") |
| | | public class BoundedQueueController { |
| | | |
| | | |
| | | @ApiOperation("添加队列数据") |
| | | @Operation(summary = "添加队列数据") |
| | | @GetMapping("/add") |
| | | public R<Void> add(@ApiParam("队列名") String queueName, |
| | | @ApiParam("容量") int capacity) { |
| | | public R<Void> add(@Parameter(name = "队列名") String queueName, |
| | | @Parameter(name = "容量") int capacity) { |
| | | // 用完了一定要销毁 否则会一直存在 |
| | | boolean b = QueueUtils.destroyBoundedQueueObject(queueName); |
| | | log.info("通道: {} , 删除: {}", queueName, b); |
| | |
| | | return R.ok("操作成功"); |
| | | } |
| | | |
| | | @ApiOperation("删除队列数据") |
| | | @Operation(summary = "删除队列数据") |
| | | @GetMapping("/remove") |
| | | public R<Void> remove(@ApiParam("队列名") String queueName) { |
| | | public R<Void> remove(@Parameter(name = "队列名") String queueName) { |
| | | String data = "data-" + 5; |
| | | if (QueueUtils.removeBoundedQueueObject(queueName, data)) { |
| | | log.info("通道: {} , 删除数据: {}", queueName, data); |
| | |
| | | return R.ok("操作成功"); |
| | | } |
| | | |
| | | @ApiOperation("获取队列数据") |
| | | @Operation(summary = "获取队列数据") |
| | | @GetMapping("/get") |
| | | public R<Void> get(@ApiParam("队列名") String queueName) { |
| | | public R<Void> get(@Parameter(name = "队列名") String queueName) { |
| | | String data; |
| | | do { |
| | | data = QueueUtils.getBoundedQueueObject(queueName); |