import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import javax.annotation.PreDestroy;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
public class Application implements ApplicationRunner
{
@Autowired
- ExecutorService executorService;
+ ThreadPoolTaskExecutor taskExecutor;
@Autowired
Consumer<?, ?> kafkaConsumer;
@Autowired
public void run(ApplicationArguments args) throws Exception
{
log.info("Starting SimpleConsumer");
- consumerJob = executorService.submit(simpleConsumer);
+ consumerJob = taskExecutor.submit(simpleConsumer);
}
@PreDestroy
import org.springframework.kafka.core.ConsumerFactory;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
@Configuration
@EnableConfigurationProperties({ KafkaProperties.class, ApplicationProperties.class })
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
-import java.time.Duration;
@ConfigurationProperties(prefix = "simple.consumer")
@NotNull
@NotEmpty
private String topic;
- private Duration throttle;
}