Ver Fonte

feat(message): kafka创建及测试

huey há 1 ano atrás
pai
commit
24257e0f59

+ 13 - 5
src/main/java/com/dragon/tj/portal/controller/MessageCenterController.java

@@ -8,15 +8,15 @@ import com.dragon.tj.portal.common.base.R;
 import com.dragon.tj.portal.common.dto.message.MessageInfoReq;
 import com.dragon.tj.portal.common.dto.notice.NoticeInfoReq;
 import com.dragon.tj.portal.component.message.MessageProducer;
+import com.dragon.tj.portal.component.page.KafkaUtil;
 import com.dragon.tj.portal.service.MessageInfoService;
 import com.dragon.tj.portal.service.NoticeInfoService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.concurrent.ExecutionException;
 
 /**
  * <p>
@@ -60,7 +60,15 @@ public class MessageCenterController {
         return noticeInfoService.send(noticeInfoReq);
     }
 
-    //topic 颁发 appcode 及
+    @Autowired
+    private KafkaUtil kafkaUtil;
+
+    @GetMapping("/createTopic")
+    public R createTopic(@RequestParam String appId,@RequestParam String topic) throws ExecutionException, InterruptedException {
+        kafkaUtil.create(topic);
+
+        return R.ok();
+    }
 
 
 }