-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/add-cors-origin
- Loading branch information
Showing
8 changed files
with
184 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/net/dancier/dancer/core/config/KafkaProducerConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package net.dancier.dancer.core.config; | ||
|
||
import org.apache.kafka.clients.producer.ProducerConfig; | ||
import org.apache.kafka.common.serialization.StringSerializer; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.kafka.core.DefaultKafkaProducerFactory; | ||
import org.springframework.kafka.core.KafkaTemplate; | ||
import org.springframework.kafka.core.ProducerFactory; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@Configuration | ||
public class KafkaProducerConfiguration { | ||
|
||
private static Logger log = LoggerFactory.getLogger(KafkaProducerConfiguration.class); | ||
@Value(value = "${spring.kafka.bootstrap-servers}") | ||
private String bootstrapAddress; | ||
|
||
@Bean | ||
ProducerFactory<String, String> producerFactory() { | ||
Map<String, Object> configProps = new HashMap<>(); | ||
configProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress); | ||
configProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); | ||
configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class); | ||
configProps.put(ProducerConfig.MAX_REQUEST_SIZE_CONFIG, "20971520"); | ||
return new DefaultKafkaProducerFactory<>(configProps); | ||
} | ||
|
||
@Bean | ||
public KafkaTemplate<String, String> kafkaTemplate() { | ||
return new KafkaTemplate<>(producerFactory()); | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/net/dancier/dancer/core/config/KafkaTopicConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package net.dancier.dancer.core.config; | ||
|
||
import org.apache.kafka.clients.admin.AdminClientConfig; | ||
import org.apache.kafka.clients.admin.NewTopic; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.kafka.core.KafkaAdmin; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@Configuration | ||
public class KafkaTopicConfig { | ||
private static Logger log = LoggerFactory.getLogger(KafkaTopicConfig.class); | ||
|
||
@Value(value = "${spring.kafka.bootstrap-servers}") | ||
private String bootstrapAddress; | ||
|
||
@Bean | ||
public KafkaAdmin kafkaAdmin() { | ||
Map<String, Object> configs = new HashMap<>(); | ||
configs.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress); | ||
return new KafkaAdmin(configs); | ||
} | ||
|
||
@Bean | ||
public NewTopic profileUpdated() { | ||
return new NewTopic("profile-updated", 1, (short) 1); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package net.dancier.dancer.output; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Profile("!test") | ||
@Component | ||
@RequiredArgsConstructor | ||
public class OutboxJob { | ||
private final Logger log = LoggerFactory.getLogger(OutboxJob.class); | ||
|
||
@Scheduled(fixedRate = 10000) | ||
public void process() { | ||
log.debug("Sending out events"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
spring: | ||
kafka: | ||
bootstrap-servers: kafka:9092 | ||
jpa: | ||
show-sql: false | ||
hibernate: | ||
|