1、生产者测试
This commit is contained in:
@@ -1,11 +1,10 @@
|
|||||||
package com.realtime.protection.server.alertmessage.kafkaConsumer;
|
package com.realtime.protection.server.alertmessage.kafkaConsumer;
|
||||||
|
|
||||||
import com.realtime.protection.configuration.entity.alert.AlertMessage;
|
import com.realtime.protection.configuration.entity.alert.AlertMessage;
|
||||||
|
import com.realtime.protection.configuration.entity.task.FiveTupleWithMask;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.kafka.core.KafkaTemplate;
|
import org.springframework.kafka.core.KafkaTemplate;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@@ -15,9 +14,22 @@ public class KafkaProducerController {
|
|||||||
this.kafkaTemplate = kafkaTemplate;
|
this.kafkaTemplate = kafkaTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/kafkasend")
|
@GetMapping("/kafkasend/{taskId}/{dynamicRuleId}")
|
||||||
public void sendMessage(@RequestBody AlertMessage alerm) {
|
public void sendMessage(@PathVariable Integer dynamicRuleId, @PathVariable Long taskId ) {
|
||||||
kafkaTemplate.send("topic-test", alerm);
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user