Skip to content

Instantly share code, notes, and snippets.

@kirshiyin89
Created October 25, 2022 12:40
Show Gist options
  • Select an option

  • Save kirshiyin89/4f4c94d744c19ae66e2afbce82c260c1 to your computer and use it in GitHub Desktop.

Select an option

Save kirshiyin89/4f4c94d744c19ae66e2afbce82c260c1 to your computer and use it in GitHub Desktop.
produce messages
@RestController
@RequiredArgsConstructor
@Slf4j
public class ProducerController {
private final KafkaTemplate<String, String> kafkaTemplate;
@Value("${topic}")
private String topic;
@GetMapping("/produce/{message}")
public void produceMessage(@PathVariable("message") final String message) {
kafkaTemplate.send(topic, message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment