package Ġcom . kafka . demo Ċ Ċ import Ġorg . springframework . boot . Spring Application Ċ import Ġorg . springframework . boot . autoconfigure . SpringBoot Application Ċ import Ġorg . springframework . boot . run Application Ċ import Ġjava . util . concurrent . Executors Ċ import Ġjava . util . concurrent . TimeUnit Ċ import Ġjava . util . concurrent . TimeoutException Ċ import Ġkotlin . system . exit Process Ċ import Ġcom . kafka . demo . util . Console Colors . ANSI _ BOLD Ċ import Ġcom . kafka . demo . util . Console Colors . ANSI _ GREEN Ċ import Ġcom . kafka . demo . util . Console Colors . ANSI _ RESET Ċ import Ġcom . kafka . demo . util . Console Colors . ANSI _ UNDER LINE Ċ import Ġcom . kafka . demo . controller . producer . Producer Wrapper Ċ Ċ @ SpringBoot Application Ċ class ĠKafka Demo Application Ċ private Ġconst Ġval ĠRUN NING _ TIME _ IN _ SECONDS Ġ= Ġ 1 5 L Ċ private Ġconst Ġval ĠI TER ATION _ INTERVAL Ġ= Ġ 2 Ċ Ċ fun Ġmain ( args : ĠArray < String >) Ġ{ Ċ ĉ val Ġapplication Ġ= Ġrun Application < Kafka Demo Application >(* args ) Ċ ĉ execute () Ċ ĉ Spring Application . exit ( application ) Ċ ĉ exit Process ( 0 ) Ċ } Ċ Ċ private Ġfun Ġexecute () Ġ{ Ċ ĉ Executors . new Single Thread Executor (). submit Ġ{ Ċĉ ĉ Producer Wrapper (). set Iteration Interval ( ITER ATION _ INTERVAL ). run () Ċ ĉ }. let Ġ{ Ċĉ ĉ try Ġ{ Ċĉĉ ĉ it . get ( RUNNING _ TIME _ IN _ SECONDS , ĠTimeUnit . SECONDS ) Ċĉ ĉ } Ġcatch Ġ( e : ĠTimeout Exception ) Ġ{ Ċĉĉ ĉ println ( ANSI _ GREEN Ġ+ ĠANSI _ BOLD Ġ+ ĠANSI _ UNDER LINE Ġ+ Ġ" Done Ġrunning Ġfor Ġ${ RUNNING _ TIME _ IN _ SECONDS } s " Ġ+ ĠANSI _ RESET ) Ċĉĉ ĉ it . cancel ( true ) Ċĉ ĉ } Ċ ĉ } Ċ } Ċ