Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

SHEEL SINDHU PRABHAKAR sheelprabhakar

🎯
Focusing
View GitHub Profile
@sheelprabhakar
sheelprabhakar / KafkaStreamConfig.java
Last active Mar 9, 2021
Kafka springboot stream config
View KafkaStreamConfig.java
@Configuration
@EnableKafka
@EnableKafkaStreams
public class KafkaStreamConfig {
@Value("${kafka.bootstrapAddress}")
private String bootstrapAddress;
@Value("${kafka.groupId}")
private String groupId;
@sheelprabhakar
sheelprabhakar / Application.java
Created Mar 6, 2021
Spring boot application with KafkaListener
View Application.java
@SpringBootApplication
@EnableScheduling
public class Application {
@Autowired
private WeatherLogService weatherLogService;
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
View WeatherLogServiceImpl.java
@Service
public class WeatherLogServiceImpl implements WeatherLogService {
private final WeatherRepository repository;
@Autowired
WeatherLogServiceImpl(final WeatherRepository repository) {
this.repository = repository;
}
@Override
public void saveLogs(WeatherLog log) throws InterruptedException {
@sheelprabhakar
sheelprabhakar / KafkaConsumerConfig.java
Last active Mar 6, 2021
Spring boot kafka consumer config
View KafkaConsumerConfig.java
@Configuration
@EnableKafka
public class KafkaConsumerConfig {
@Value( "${kafka.bootstrapAddress}" )
private String bootstrapAddress;
@Value( "${kafka.groupId}" )
private String groupId;
@Bean
@sheelprabhakar
sheelprabhakar / db.sql
Last active Mar 6, 2021
Postgreas partioned table sample script
View db.sql
CREATE TABLE weather.log
(
city character varying(255) COLLATE pg_catalog."default" NOT NULL,
latitude double precision NOT NULL,
longitude double precision NOT NULL,
temp double precision NOT NULL,
logdate date NOT NULL,
id integer NOT NULL
) PARTITION BY RANGE (logdate);
@sheelprabhakar
sheelprabhakar / Application.java
Last active Mar 6, 2021
Spring boot application to execute a task every hour
View Application.java
@SpringBootApplication
@EnableScheduling
public class Application {
@Autowired
private WeatherAgentService weatherAgentService;
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@sheelprabhakar
sheelprabhakar / WeatherAgentServiceImpl.java
Created Mar 6, 2021
Spring service to generate simulation data for cities temprature
View WeatherAgentServiceImpl.java
@Service
public class WeatherAgentServiceImpl implements WeatherAgentService {
private final CityRepository cityRepository;
private final ExecutorService executor;
private final KafkaTemplate<String, WeatherInfo> kafkaTemplate;
private final Random rand = new Random();
private final int min = -20;
private final int max = 50;
@Autowired
public WeatherAgentServiceImpl(CityRepository cityRepository, KafkaTemplate<String, WeatherInfo> kafkaTemplate) {
@sheelprabhakar
sheelprabhakar / KafkaProducerConfig.java
Created Mar 6, 2021
Kafka Spring config for producer
View KafkaProducerConfig.java
@Configuration
public class KafkaProducerConfig {
@Value( "${kafka.bootstrapAddress}" )
private String bootstrapAddress;
@Bean
public ProducerFactory<String, WeatherInfo> producerFactory() {
Map<String, Object> configProps = new HashMap<>();
configProps.put(
ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,
@sheelprabhakar
sheelprabhakar / KafkaTopicConfig.java
Last active Mar 6, 2021
Spring config for Kafka Topic
View KafkaTopicConfig.java
@Configuration
public class KafkaTopicConfig {
@Value("${kafka.bootstrapAddress}")
private String bootstrapAddress;
@Bean
public KafkaAdmin kafkaAdmin() {
Map<String, Object> configs = new HashMap<>();
configs.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress);