package com.usky.controller.web; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; 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; @RestController @RequestMapping("/api") public class RocketMqController { @Autowired private RocketMQTemplate rocketMQTemplate; @GetMapping("/pushMessage") public String pushMessage(@RequestParam("str") String str) { rocketMQTemplate.convertAndSend("entrance-topic","你好,RocketMq =>" + str); return "success"; } }