diff --git a/src/main/java/com/realtime/protection/server/alertmessage/kafkaConsumer/KafkaProducerController.java b/src/main/java/com/realtime/protection/server/alertmessage/kafkaConsumer/KafkaProducerController.java index bb24d19..ae2d672 100644 --- a/src/main/java/com/realtime/protection/server/alertmessage/kafkaConsumer/KafkaProducerController.java +++ b/src/main/java/com/realtime/protection/server/alertmessage/kafkaConsumer/KafkaProducerController.java @@ -1,11 +1,10 @@ package com.realtime.protection.server.alertmessage.kafkaConsumer; import com.realtime.protection.configuration.entity.alert.AlertMessage; +import com.realtime.protection.configuration.entity.task.FiveTupleWithMask; import lombok.extern.slf4j.Slf4j; import org.springframework.kafka.core.KafkaTemplate; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @Slf4j @RestController @@ -15,9 +14,22 @@ public class KafkaProducerController { this.kafkaTemplate = kafkaTemplate; } - @PostMapping("/kafkasend") - public void sendMessage(@RequestBody AlertMessage alerm) { - kafkaTemplate.send("topic-test", alerm); + @GetMapping("/kafkasend/{taskId}/{dynamicRuleId}") + public void sendMessage(@PathVariable Integer dynamicRuleId, @PathVariable Long taskId ) { + AlertMessage alert = new AlertMessage(); + + FiveTupleWithMask fiveTupleWithMask = new FiveTupleWithMask(); + fiveTupleWithMask.setSourceIP("1.1.1.1"); + fiveTupleWithMask.setSourcePort("80"); + fiveTupleWithMask.setDestinationIP("2.2.2.2"); + fiveTupleWithMask.setDestinationPort("80"); + fiveTupleWithMask.setProtocol("TCP"); + + alert.setDynamicRuleId(dynamicRuleId); + alert.setTaskId(taskId); + alert.setFiveTupleWithMask(fiveTupleWithMask); + alert.setContent("testcontent"); + kafkaTemplate.send("topic-alert", alert); }