PrepZone Logo
PrepZone
Back to AI Coding

AI Coding · Hard

Review this AI-generated Kafka consumer that writes events to the database.

AI CodingCode ReviewStaff

Consumer uses enable.auto.commit=true.

java
@KafkaListener(topics = "orders")
public void onOrder(OrderEvent event) {
    try {
        orderRepository.save(toEntity(event));
        emailService.sendConfirmation(event.customerEmail());
    } catch (Exception e) {
        log.error("failed", e);
    }
}