-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added kafka support library * Added kafka prop * Added configuration of kafka * Added order repository to communicate with order micor service using kafka * Changes done in controller * Changes done in service * FIXED: build fail * Reduce coverage limit
- Loading branch information
Showing
7 changed files
with
81 additions
and
4 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
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/com/example/backendcart/config/ReactiveKafkaProducerConfig.kt
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,19 @@ | ||
package com.example.backendcart.config | ||
|
||
import com.hrv.mart.orderlibrary.model.OrderRequest | ||
import org.springframework.boot.autoconfigure.kafka.KafkaProperties | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.kafka.core.reactive.ReactiveKafkaProducerTemplate | ||
import reactor.kafka.sender.SenderOptions | ||
|
||
@Configuration | ||
class ReactiveKafkaProducerConfig { | ||
@Bean | ||
fun reactiveKafkaProducerTemplate( | ||
properties: KafkaProperties | ||
): ReactiveKafkaProducerTemplate<String, OrderRequest> { | ||
val props = properties.buildProducerProperties() | ||
return ReactiveKafkaProducerTemplate<String, OrderRequest>(SenderOptions.create(props)) | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/com/example/backendcart/repository/OrderRepository.kt
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,17 @@ | ||
package com.example.backendcart.repository | ||
|
||
import com.hrv.mart.orderlibrary.model.OrderRequest | ||
import com.hrv.mart.orderlibrary.service.OrderProducer | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.kafka.core.reactive.ReactiveKafkaProducerTemplate | ||
import org.springframework.stereotype.Repository | ||
|
||
@Repository | ||
class OrderRepository ( | ||
@Autowired | ||
private val kafkaTemplate: ReactiveKafkaProducerTemplate<String, OrderRequest>, | ||
) { | ||
private val orderProducer = OrderProducer(kafkaTemplate) | ||
fun createOrder(orderRequest: OrderRequest) = | ||
orderProducer.createOrder(orderRequest) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
spring.data.mongodb.uri=${MONGODB_URI} | ||
spring.data.mongodb.database=HRV-Mart-Backend-Cart | ||
server.port=${APPLICATION_PORT} | ||
spring.data.mongodb.auto-index-creation=true | ||
spring.data.mongodb.auto-index-creation=true | ||
spring.kafka.producer.bootstrap-servers: localhost:9092 | ||
spring.kafka.producer.key-serializer: org.apache.kafka.common.serialization.StringSerializer | ||
spring.kafka.producer.value-serializer: org.springframework.kafka.support.serializer.JsonSerializer | ||
spring.kafka.consumer.group-id=order |
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