xuekang
2024-05-10 edf3b7fde038fcf3e6d86b8b4b88c2ff6f9014cf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package org.dromara.stream.controller;
 
import org.dromara.common.core.domain.R;
import org.dromara.stream.mq.producer.DelayProducer;
import org.dromara.stream.mq.producer.LogStreamProducer;
import org.dromara.stream.mq.producer.TestStreamProducer;
import lombok.AllArgsConstructor;
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.RestController;
 
/**
 * 测试mq
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/test-mq")
public class TestMqController {
 
    private final DelayProducer delayProducer;
    private final TestStreamProducer testStreamProducer;
    private final LogStreamProducer logStreamProducer;
 
    /**
     * 发送消息Rabbitmq
     *
     * @param msg 消息内容
     * @param delay 延时时间
     */
    @GetMapping("/sendRabbitmq")
    public R<Void> sendRabbitmq(String msg, Long delay) {
        delayProducer.sendMsg(msg, delay);
        return R.ok();
    }
 
    /**
     * 发送消息Rocketmq
     *
     * @param msg 消息内容
     */
    @GetMapping("/sendRocketmq")
    public R<Void> sendRocketmq(String msg) {
        testStreamProducer.streamTestMsg(msg);
        return R.ok();
    }
 
    /**
     * 发送消息Kafka
     *
     * @param msg 消息内容
     */
    @GetMapping("/sendKafka")
    public R<Void> sendKafka(String msg) {
        logStreamProducer.streamLogMsg(msg);
        return R.ok();
    }
 
}