Guest User

Untitled

a guest
May 18th, 2021
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.59 KB | None | 0 0
  1. #!/usr/bin/env -S ocaml -w +A
  2.  
  3. #use "topfind";;
  4.  
  5. #load "unix.cma";;
  6. #thread;;
  7.  
  8. #require "kafka";;
  9. #require "kafka_lwt";;
  10.  
  11. open Lwt.Infix
  12.  
  13. let () =
  14.   Lwt_main.run begin
  15.     let producer = Kafka.new_producer ["bootstrap.servers","localhost:9092"] in
  16.     let producer_topic = Kafka.new_topic producer "fuck" [] in
  17.  
  18.     let partition = 0 in
  19.  
  20.     (* Produce some messages *)
  21.     Kafka_lwt.produce producer_topic partition "message 0" >>= fun () ->
  22.     Kafka_lwt.produce producer_topic partition "message 1" >>= fun () ->
  23.     Kafka_lwt.produce producer_topic partition "message 2"
  24.   end
  25.  
Add Comment
Please, Sign In to add comment