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
@Service | |
@Slf4j | |
@AllArgsConstructor | |
public class UserService { | |
private final KafkaProducer kafkaProducer; | |
private static final String USER_TOPIC = "user-create"; | |
public Mono<String> userCreate(Mono<UserDto> username){ | |
return username.flatMap(name -> |
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
@Configuration | |
@AllArgsConstructor | |
public class KafkaProducer { | |
private static final String BOOTSTRAP_SERVERS = "localhost:9092"; | |
/** | |
* Building kafka producer configurations | |
* */ | |
@Bean |
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
. | |
. | |
. | |
<dependencies> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-webflux</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>org.springframework.kafka</groupId> |
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
@Getter | |
@Setter | |
public class ProductDto { | |
public ProductDto(Long id, String title, BigDecimal price, String imagePath, String owner) { | |
this.id = id; | |
this.title = title; | |
this.price = price; | |
this.imagePath = imagePath; | |
this.owner = owner; |
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
@RestController | |
@RequestMapping("api/product") | |
@AllArgsConstructor | |
public class ProductController { | |
private final ProductService productService; | |
@GetMapping("findAll") | |
public List<ProductDto> findAll() { | |
return productService.getProducts(); |
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
public class ProductService { | |
List<ProductDto> products = new ArrayList<ProductDto>(); | |
ProductDto product; | |
public List<ProductDto> getProducts(){ | |
return products; | |
} | |
public ProductDto get(Long id) throws ClassNotFoundException{ |