Commit 394fa93b authored by Sarika Sama's avatar Sarika Sama

integrating kafka

parent 940b786c
......@@ -22,6 +22,7 @@ public class KafkaConsumerConfig {
@Bean
public ConsumerFactory<String, String> consumerFatory() {
Map<String, Object> config = new HashMap<>();
config.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
config.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
......
......@@ -9,6 +9,7 @@ import org.springframework.stereotype.Component;
@Component
@Slf4j
public class KafkaListeners {
@Value("${order_topic}")
private String topicName;
......
......@@ -9,6 +9,7 @@ import org.springframework.stereotype.Component;
@Component
@Slf4j
public class KafkaProducer {
private final KafkaTemplate<String, String> kafkaTemplate;
@Autowired
......
......@@ -18,6 +18,7 @@ public class KafkaProducerConfig {
@Bean
ProducerFactory<String, String> producerFactory() {
Map<String, Object> config = new HashMap<>();
config.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
config.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
......
......@@ -28,6 +28,7 @@ public class OrdersService {
private String topicName;
public Flux<Order> fetchOrdersAndPublish(){
Flux<Order> orders = orderRepository.findAll();
Mono<List<Order>> ordersMono = orders.collectList()
......
......@@ -18,6 +18,7 @@ public class UserOrdersService {
ReactiveMongoTemplate reactiveMongoTemplate;
public Flux<UserOrders> getAllUsersWithOrders() {
LookupOperation lookupOperation = LookupOperation.newLookup().
from("orders").
localField("userId").
......
......@@ -14,6 +14,7 @@ public class UserService {
private UserRepository userRepository;
public Flux<User> getUsers(){
return userRepository.findAll();
}
......
server.port=9090
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=user-orders-db
order_topic=order_topic
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment