Spring Boot Kafka issue: MessageConversionException: Cannot convert from [java.lang.String] to [my_custom_model] for GenericMessage […]

I am following a tutorial until timestamp: 05:54:05
🚀 🔥 Mastering Micro-services: Spring boot, Spring Cloud and Keycloak In 7 Hours -> Timestamp: 05:54:05

Here is the link for the project Github Repo

and got the following exception:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>2024-09-10T16:10:49.762-07:00 ERROR 92288 --- Backoff FixedBackOff{interval=0, currentAttempts=1, maxAttempts=0} exhausted for payment-topic-0@5
Listener method could not be invoked with the incoming message
Endpoint handler details:
Method [public void com.microservices.ecommerce.kafka.NotificationConsumer.consumePaymentSuccessNotification(com.microservices.ecommerce.kafka.payment.PaymentConfirmation) throws jakarta.mail.MessagingException]
Bean [com.microservices.ecommerce.kafka.NotificationConsumer@6615ccb6]
Caused by: org.springframework.messaging.converter.MessageConversionException: Cannot handle message
Caused by: org.springframework.messaging.converter.MessageConversionException: Cannot convert from [java.lang.String] to [com.microservices.ecommerce.kafka.payment.PaymentConfirmation] for GenericMessage [payload={"orderReference":"MS-20241201","amount":900,"paymentMethod":"PAYPAL","customerFirstname":null,"customerLastname":null,"customerEmail":"[email protected]"}, headers={kafka_offset=5, kafka_consumer=org.springframework.kafka.core.DefaultKafkaConsumerFactory$ExtendedKafkaConsumer@3543a9a7, kafka_timestampType=CREATE_TIME, kafka_receivedPartitionId=0, kafka_receivedTopic=payment-topic, kafka_receivedTimestamp=1726009849728, __TypeId__=[B@16b8789b, kafka_groupId=paymentGroup}]
2024-09-10T16:10:49.762-07:00 ERROR 92288 --- Backoff FixedBackOff{interval=0, currentAttempts=1, maxAttempts=0} exhausted for order-topic-0@5
ListenerExecutionFailedException: Listener method could not be invoked with the incoming message
Endpoint handler details:
Method [public void com.microservices.ecommerce.kafka.NotificationConsumer.consumeOrderConfirmationNotification(com.microservices.ecommerce.kafka.order.OrderConfirmation) throws jakarta.mail.MessagingException]
Bean [com.microservices.ecommerce.kafka.NotificationConsumer@6615ccb6]
Caused by: org.springframework.messaging.converter.MessageConversionException: Cannot handle message
Caused by: org.springframework.messaging.converter.MessageConversionException: Cannot convert from [java.lang.String] to [com.microservices.ecommerce.kafka.order.OrderConfirmation] for GenericMessage [payload={"orderReference":"MS-20241201","totalAmount":900,"paymentMethod":"PAYPAL","customerResponse":{"id":"66e09b55f7786369d16fdfff","firstname":null,"lastname":null,"email":"[email protected]"},"products":[{"productId":1,"name":"Mechanical Keyboard 1","description":"Mechanical keyboard with RGB lighting","price":99.99,"quantity":1.0},{"productId":251,"name":"4K Monitor 1","description":"27-inch IPS monitor with 4K resolution","price":399.99,"quantity":1.0},{"productId":851,"name":"Ambidextrous Gaming Mouse 1","description":"Ambidextrous gaming mouse with high DPI","price":69.99,"quantity":1.0}]}, headers={kafka_offset=5, kafka_consumer=org.springframework.kafka.core.DefaultKafkaConsumerFactory$ExtendedKafkaConsumer@33222867, kafka_timestampType=CREATE_TIME, kafka_receivedPartitionId=0, kafka_receivedTopic=order-topic, kafka_receivedTimestamp=1726009849737, __TypeId__=[B@7436f23e, kafka_groupId=orderGroup}]
</code>
<code>2024-09-10T16:10:49.762-07:00 ERROR 92288 --- Backoff FixedBackOff{interval=0, currentAttempts=1, maxAttempts=0} exhausted for payment-topic-0@5 Listener method could not be invoked with the incoming message Endpoint handler details: Method [public void com.microservices.ecommerce.kafka.NotificationConsumer.consumePaymentSuccessNotification(com.microservices.ecommerce.kafka.payment.PaymentConfirmation) throws jakarta.mail.MessagingException] Bean [com.microservices.ecommerce.kafka.NotificationConsumer@6615ccb6] Caused by: org.springframework.messaging.converter.MessageConversionException: Cannot handle message Caused by: org.springframework.messaging.converter.MessageConversionException: Cannot convert from [java.lang.String] to [com.microservices.ecommerce.kafka.payment.PaymentConfirmation] for GenericMessage [payload={"orderReference":"MS-20241201","amount":900,"paymentMethod":"PAYPAL","customerFirstname":null,"customerLastname":null,"customerEmail":"[email protected]"}, headers={kafka_offset=5, kafka_consumer=org.springframework.kafka.core.DefaultKafkaConsumerFactory$ExtendedKafkaConsumer@3543a9a7, kafka_timestampType=CREATE_TIME, kafka_receivedPartitionId=0, kafka_receivedTopic=payment-topic, kafka_receivedTimestamp=1726009849728, __TypeId__=[B@16b8789b, kafka_groupId=paymentGroup}] 2024-09-10T16:10:49.762-07:00 ERROR 92288 --- Backoff FixedBackOff{interval=0, currentAttempts=1, maxAttempts=0} exhausted for order-topic-0@5 ListenerExecutionFailedException: Listener method could not be invoked with the incoming message Endpoint handler details: Method [public void com.microservices.ecommerce.kafka.NotificationConsumer.consumeOrderConfirmationNotification(com.microservices.ecommerce.kafka.order.OrderConfirmation) throws jakarta.mail.MessagingException] Bean [com.microservices.ecommerce.kafka.NotificationConsumer@6615ccb6] Caused by: org.springframework.messaging.converter.MessageConversionException: Cannot handle message Caused by: org.springframework.messaging.converter.MessageConversionException: Cannot convert from [java.lang.String] to [com.microservices.ecommerce.kafka.order.OrderConfirmation] for GenericMessage [payload={"orderReference":"MS-20241201","totalAmount":900,"paymentMethod":"PAYPAL","customerResponse":{"id":"66e09b55f7786369d16fdfff","firstname":null,"lastname":null,"email":"[email protected]"},"products":[{"productId":1,"name":"Mechanical Keyboard 1","description":"Mechanical keyboard with RGB lighting","price":99.99,"quantity":1.0},{"productId":251,"name":"4K Monitor 1","description":"27-inch IPS monitor with 4K resolution","price":399.99,"quantity":1.0},{"productId":851,"name":"Ambidextrous Gaming Mouse 1","description":"Ambidextrous gaming mouse with high DPI","price":69.99,"quantity":1.0}]}, headers={kafka_offset=5, kafka_consumer=org.springframework.kafka.core.DefaultKafkaConsumerFactory$ExtendedKafkaConsumer@33222867, kafka_timestampType=CREATE_TIME, kafka_receivedPartitionId=0, kafka_receivedTopic=order-topic, kafka_receivedTimestamp=1726009849737, __TypeId__=[B@7436f23e, kafka_groupId=orderGroup}] </code>
2024-09-10T16:10:49.762-07:00 ERROR 92288 --- Backoff FixedBackOff{interval=0, currentAttempts=1, maxAttempts=0} exhausted for payment-topic-0@5

Listener method could not be invoked with the incoming message
Endpoint handler details:
Method [public void com.microservices.ecommerce.kafka.NotificationConsumer.consumePaymentSuccessNotification(com.microservices.ecommerce.kafka.payment.PaymentConfirmation) throws jakarta.mail.MessagingException]
Bean [com.microservices.ecommerce.kafka.NotificationConsumer@6615ccb6]
    

Caused by: org.springframework.messaging.converter.MessageConversionException: Cannot handle message
    
Caused by: org.springframework.messaging.converter.MessageConversionException:  Cannot convert from [java.lang.String] to [com.microservices.ecommerce.kafka.payment.PaymentConfirmation] for GenericMessage [payload={"orderReference":"MS-20241201","amount":900,"paymentMethod":"PAYPAL","customerFirstname":null,"customerLastname":null,"customerEmail":"[email protected]"}, headers={kafka_offset=5, kafka_consumer=org.springframework.kafka.core.DefaultKafkaConsumerFactory$ExtendedKafkaConsumer@3543a9a7, kafka_timestampType=CREATE_TIME, kafka_receivedPartitionId=0, kafka_receivedTopic=payment-topic, kafka_receivedTimestamp=1726009849728, __TypeId__=[B@16b8789b, kafka_groupId=paymentGroup}]

2024-09-10T16:10:49.762-07:00 ERROR 92288 --- Backoff FixedBackOff{interval=0, currentAttempts=1, maxAttempts=0} exhausted for order-topic-0@5

ListenerExecutionFailedException: Listener method could not be invoked with the incoming message
Endpoint handler details:
Method [public void com.microservices.ecommerce.kafka.NotificationConsumer.consumeOrderConfirmationNotification(com.microservices.ecommerce.kafka.order.OrderConfirmation) throws jakarta.mail.MessagingException]
Bean [com.microservices.ecommerce.kafka.NotificationConsumer@6615ccb6]

Caused by: org.springframework.messaging.converter.MessageConversionException: Cannot handle message

Caused by: org.springframework.messaging.converter.MessageConversionException: Cannot convert from [java.lang.String] to [com.microservices.ecommerce.kafka.order.OrderConfirmation] for GenericMessage [payload={"orderReference":"MS-20241201","totalAmount":900,"paymentMethod":"PAYPAL","customerResponse":{"id":"66e09b55f7786369d16fdfff","firstname":null,"lastname":null,"email":"[email protected]"},"products":[{"productId":1,"name":"Mechanical Keyboard 1","description":"Mechanical keyboard with RGB lighting","price":99.99,"quantity":1.0},{"productId":251,"name":"4K Monitor 1","description":"27-inch IPS monitor with 4K resolution","price":399.99,"quantity":1.0},{"productId":851,"name":"Ambidextrous Gaming Mouse 1","description":"Ambidextrous gaming mouse with high DPI","price":69.99,"quantity":1.0}]}, headers={kafka_offset=5, kafka_consumer=org.springframework.kafka.core.DefaultKafkaConsumerFactory$ExtendedKafkaConsumer@33222867, kafka_timestampType=CREATE_TIME, kafka_receivedPartitionId=0, kafka_receivedTopic=order-topic, kafka_receivedTimestamp=1726009849737, __TypeId__=[B@7436f23e, kafka_groupId=orderGroup}]

Long story short, this micro-service project structure:
[ Producer: order-service & payment-service –> Consumer: notification-service ]

I think the problem may coming from consumer due to producer had successfully sent the confirmation:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>2024-09-10T16:10:49.732-07:00 INFO 47674 --- Sending order confirmation: OrderConfirmation[orderReference=MS-20241201, totalAmount=900, paymentMethod=PAYPAL, customerResponse=CustomerResponse[id=xxxx, xxx=null, xxx=null, [email protected]], products=[PurchaseResponse[productId=1, name=Mechanical Keyboard 1, description=Mechanical keyboard with RGB lighting, price=99.99, quantity=1.0], PurchaseResponse[productId=251, name=4K Monitor 1, description=27-inch IPS monitor with 4K resolution, price=399.99, quantity=1.0], PurchaseResponse[productId=851, name=Ambidextrous Gaming Mouse 1, description=Ambidextrous gaming mouse with high DPI, price=69.99, quantity=1.0]]]
</code>
<code>2024-09-10T16:10:49.732-07:00 INFO 47674 --- Sending order confirmation: OrderConfirmation[orderReference=MS-20241201, totalAmount=900, paymentMethod=PAYPAL, customerResponse=CustomerResponse[id=xxxx, xxx=null, xxx=null, [email protected]], products=[PurchaseResponse[productId=1, name=Mechanical Keyboard 1, description=Mechanical keyboard with RGB lighting, price=99.99, quantity=1.0], PurchaseResponse[productId=251, name=4K Monitor 1, description=27-inch IPS monitor with 4K resolution, price=399.99, quantity=1.0], PurchaseResponse[productId=851, name=Ambidextrous Gaming Mouse 1, description=Ambidextrous gaming mouse with high DPI, price=69.99, quantity=1.0]]] </code>
2024-09-10T16:10:49.732-07:00  INFO 47674 --- Sending order confirmation: OrderConfirmation[orderReference=MS-20241201, totalAmount=900, paymentMethod=PAYPAL, customerResponse=CustomerResponse[id=xxxx, xxx=null, xxx=null, [email protected]], products=[PurchaseResponse[productId=1, name=Mechanical Keyboard 1, description=Mechanical keyboard with RGB lighting, price=99.99, quantity=1.0], PurchaseResponse[productId=251, name=4K Monitor 1, description=27-inch IPS monitor with 4K resolution, price=399.99, quantity=1.0], PurchaseResponse[productId=851, name=Ambidextrous Gaming Mouse 1, description=Ambidextrous gaming mouse with high DPI, price=69.99, quantity=1.0]]]

Hence the problem should coming from consumer unable to transfer String to Json format:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>Cannot convert from [java.lang.String] to [] for GenericMessage [xxx]
</code>
<code>Cannot convert from [java.lang.String] to [] for GenericMessage [xxx] </code>
Cannot convert from [java.lang.String] to [] for GenericMessage [xxx]
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>order-service.yml
spring:
datasource:
url: jdbc:postgresql://localhost:5432/order
username: root
password: 123456
driver-class-name: org.postgresql.Driver
jpa:
hibernate:
ddl-auto: create
database: postgresql
database-platform: org.hibernate.dialect.PostgreSQLDialect
kafka:
producer:
bootstrap-servers: "localhost:9092"
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: org.springframework.kafka.support.serializer.JsonSerializer
properties:
spring.json.type.mapping: orderConfirmation:com.microservices.ecommerce.kafka.OrderConfirmation
server:
port: 8070
application:
config:
customer-url: http://localhost:8222/api/v1/customers
payment-url: http://localhost:8222/api/v1/payments
product-url: http://localhost:8222/api/v1/products
</code>
<code>order-service.yml spring: datasource: url: jdbc:postgresql://localhost:5432/order username: root password: 123456 driver-class-name: org.postgresql.Driver jpa: hibernate: ddl-auto: create database: postgresql database-platform: org.hibernate.dialect.PostgreSQLDialect kafka: producer: bootstrap-servers: "localhost:9092" key-serializer: org.apache.kafka.common.serialization.StringSerializer value-serializer: org.springframework.kafka.support.serializer.JsonSerializer properties: spring.json.type.mapping: orderConfirmation:com.microservices.ecommerce.kafka.OrderConfirmation server: port: 8070 application: config: customer-url: http://localhost:8222/api/v1/customers payment-url: http://localhost:8222/api/v1/payments product-url: http://localhost:8222/api/v1/products </code>
order-service.yml

spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/order
    username: root
    password: 123456
    driver-class-name: org.postgresql.Driver
  jpa:
    hibernate:
      ddl-auto: create
    database: postgresql
    database-platform: org.hibernate.dialect.PostgreSQLDialect
  kafka:
    producer:
      bootstrap-servers: "localhost:9092"
      key-serializer: org.apache.kafka.common.serialization.StringSerializer
      value-serializer: org.springframework.kafka.support.serializer.JsonSerializer
      properties:
        spring.json.type.mapping: orderConfirmation:com.microservices.ecommerce.kafka.OrderConfirmation

server:
  port: 8070

application:
  config:
    customer-url: http://localhost:8222/api/v1/customers
    payment-url: http://localhost:8222/api/v1/payments
    product-url: http://localhost:8222/api/v1/products

payment-service.yml

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>
spring:
datasource:
url: jdbc:postgresql://localhost:5432/payment
username: root
password: 123456
driver-class-name: org.postgresql.Driver
jpa:
hibernate:
ddl-auto: update
database: postgresql
database-platform: org.hibernate.dialect.PostgreSQLDialect
kafka:
producer:
bootstrap-servers: "localhost:9092"
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: org.springframework.kafka.support.serializer.JsonSerializer
properties:
spring.json.type.mapping: paymentConfirmation:com.microservices.ecommerce.notification.PaymentNotificationRequest
server:
port: 8060
</code>
<code> spring: datasource: url: jdbc:postgresql://localhost:5432/payment username: root password: 123456 driver-class-name: org.postgresql.Driver jpa: hibernate: ddl-auto: update database: postgresql database-platform: org.hibernate.dialect.PostgreSQLDialect kafka: producer: bootstrap-servers: "localhost:9092" key-serializer: org.apache.kafka.common.serialization.StringSerializer value-serializer: org.springframework.kafka.support.serializer.JsonSerializer properties: spring.json.type.mapping: paymentConfirmation:com.microservices.ecommerce.notification.PaymentNotificationRequest server: port: 8060 </code>


spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/payment
    username: root
    password: 123456
    driver-class-name: org.postgresql.Driver
  jpa:
    hibernate:
      ddl-auto: update
    database: postgresql
    database-platform: org.hibernate.dialect.PostgreSQLDialect

  kafka:
    producer:
      bootstrap-servers: "localhost:9092"
      key-serializer: org.apache.kafka.common.serialization.StringSerializer
      value-serializer: org.springframework.kafka.support.serializer.JsonSerializer
      properties:
        spring.json.type.mapping: paymentConfirmation:com.microservices.ecommerce.notification.PaymentNotificationRequest

server:
  port: 8060

notification-service.yml

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>
spring:
kafka:
consumer:
bootstrap-servers: "localhost:9092"
group-id: paymentGroup,orderGroup
auto-offset-reset: earliest
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
value-deserializer: org.springframework.kafka.support.serializer.JsonDeserializer
properties:
spring.json.trusted.packages: '*'
spring.json.type.mapping: orderConfirmation:com.microservices.ecommerce.kafka.order.OrderConfirmation,paymentConfirmation:com.microservices.ecommerce.kafka.payment.PaymentConfirmation
mail:
host: localhost
port: 1025
username: root
password: 123456
properties:
mail:
smtp:
ssl:
trust: "*"
auth: true
starttls:
enable: true
required: true
connectiontimeout: 5000
timeout: 3000
writetimeout: 5000
server:
port: 8040
</code>
<code> spring: kafka: consumer: bootstrap-servers: "localhost:9092" group-id: paymentGroup,orderGroup auto-offset-reset: earliest key-deserializer: org.apache.kafka.common.serialization.StringDeserializer value-deserializer: org.springframework.kafka.support.serializer.JsonDeserializer properties: spring.json.trusted.packages: '*' spring.json.type.mapping: orderConfirmation:com.microservices.ecommerce.kafka.order.OrderConfirmation,paymentConfirmation:com.microservices.ecommerce.kafka.payment.PaymentConfirmation mail: host: localhost port: 1025 username: root password: 123456 properties: mail: smtp: ssl: trust: "*" auth: true starttls: enable: true required: true connectiontimeout: 5000 timeout: 3000 writetimeout: 5000 server: port: 8040 </code>

spring:
  kafka:
    consumer:
      bootstrap-servers: "localhost:9092"
      group-id: paymentGroup,orderGroup
      auto-offset-reset: earliest
      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value-deserializer: org.springframework.kafka.support.serializer.JsonDeserializer
      properties:
        spring.json.trusted.packages: '*'
        spring.json.type.mapping: orderConfirmation:com.microservices.ecommerce.kafka.order.OrderConfirmation,paymentConfirmation:com.microservices.ecommerce.kafka.payment.PaymentConfirmation
  mail:
    host: localhost
    port: 1025
    username: root
    password: 123456

    properties:
      mail:
        smtp:
          ssl:
            trust: "*"
          auth: true
          starttls:
            enable: true
            required: true
          connectiontimeout: 5000
          timeout: 3000
          writetimeout: 5000

server:
  port: 8040

notificationConsumer.java

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>
@Service
@RequiredArgsConstructor
@Slf4j
public class NotificationConsumer {
private final NotificationRepository repository;
private final EmailService emailService;
@KafkaListener(topics = "payment-topic", groupId = "paymentGroup", containerFactory = "kafkaListenerContainerFactory")
public void consumePaymentSuccessNotification(PaymentConfirmation paymentConfirmation) throws MessagingException {
log.info("Consuming the message from payment-topic Topic:: {}", paymentConfirmation.toString());
repository.save(
Notification.builder()
.type(PAYMENT_CONFIRMATION)
.notificationDate(LocalDateTime.now())
.paymentConfirmation(paymentConfirmation)
.build()
);
var customerName = paymentConfirmation.customerFirstname() + " " + paymentConfirmation.customerLastname();
emailService.sendPaymentSuccessEmail(
paymentConfirmation.customerEmail(),
customerName,
paymentConfirmation.amount(),
paymentConfirmation.orderReference()
);
}
@KafkaListener(topics = "order-topic", groupId = "orderGroup", containerFactory = "kafkaListenerContainerFactory")
public void consumeOrderConfirmationNotification(OrderConfirmation orderConfirmation) throws MessagingException {
log.info("Consuming the message from order-topic Topic:: {}", orderConfirmation.toString());
repository.save(
Notification.builder()
.type(ORDER_CONFIRMATION)
.notificationDate(LocalDateTime.now())
.orderConfirmation(orderConfirmation)
.build()
);
// TODO send email
var customerName = orderConfirmation.customer().firstname() + " " + orderConfirmation.customer().lastname();
emailService.sendOrderConfirmationEmail(
orderConfirmation.customer().email(),
customerName,
orderConfirmation.totalAmount(),
orderConfirmation.orderReference(),
orderConfirmation.products()
);
}
}
</code>
<code> @Service @RequiredArgsConstructor @Slf4j public class NotificationConsumer { private final NotificationRepository repository; private final EmailService emailService; @KafkaListener(topics = "payment-topic", groupId = "paymentGroup", containerFactory = "kafkaListenerContainerFactory") public void consumePaymentSuccessNotification(PaymentConfirmation paymentConfirmation) throws MessagingException { log.info("Consuming the message from payment-topic Topic:: {}", paymentConfirmation.toString()); repository.save( Notification.builder() .type(PAYMENT_CONFIRMATION) .notificationDate(LocalDateTime.now()) .paymentConfirmation(paymentConfirmation) .build() ); var customerName = paymentConfirmation.customerFirstname() + " " + paymentConfirmation.customerLastname(); emailService.sendPaymentSuccessEmail( paymentConfirmation.customerEmail(), customerName, paymentConfirmation.amount(), paymentConfirmation.orderReference() ); } @KafkaListener(topics = "order-topic", groupId = "orderGroup", containerFactory = "kafkaListenerContainerFactory") public void consumeOrderConfirmationNotification(OrderConfirmation orderConfirmation) throws MessagingException { log.info("Consuming the message from order-topic Topic:: {}", orderConfirmation.toString()); repository.save( Notification.builder() .type(ORDER_CONFIRMATION) .notificationDate(LocalDateTime.now()) .orderConfirmation(orderConfirmation) .build() ); // TODO send email var customerName = orderConfirmation.customer().firstname() + " " + orderConfirmation.customer().lastname(); emailService.sendOrderConfirmationEmail( orderConfirmation.customer().email(), customerName, orderConfirmation.totalAmount(), orderConfirmation.orderReference(), orderConfirmation.products() ); } } </code>


@Service
@RequiredArgsConstructor
@Slf4j
public class NotificationConsumer {

    private final NotificationRepository repository;
    private final EmailService emailService;
    
    @KafkaListener(topics = "payment-topic", groupId = "paymentGroup", containerFactory = "kafkaListenerContainerFactory")
    public void consumePaymentSuccessNotification(PaymentConfirmation paymentConfirmation) throws MessagingException {
        log.info("Consuming the message from payment-topic Topic:: {}", paymentConfirmation.toString());
        repository.save(
                Notification.builder()
                        .type(PAYMENT_CONFIRMATION)
                        .notificationDate(LocalDateTime.now())
                        .paymentConfirmation(paymentConfirmation)
                        .build()
        );

        var customerName = paymentConfirmation.customerFirstname() + " " + paymentConfirmation.customerLastname();
        emailService.sendPaymentSuccessEmail(
                paymentConfirmation.customerEmail(),
                customerName,
                paymentConfirmation.amount(),
                paymentConfirmation.orderReference()
        );
    }

    @KafkaListener(topics = "order-topic", groupId = "orderGroup", containerFactory = "kafkaListenerContainerFactory")
    public void consumeOrderConfirmationNotification(OrderConfirmation orderConfirmation) throws MessagingException {
        log.info("Consuming the message from order-topic Topic:: {}", orderConfirmation.toString());
        repository.save(
                Notification.builder()
                        .type(ORDER_CONFIRMATION)
                        .notificationDate(LocalDateTime.now())
                        .orderConfirmation(orderConfirmation)
                        .build()
        );

        // TODO send email
        var customerName = orderConfirmation.customer().firstname() + " " + orderConfirmation.customer().lastname();
        emailService.sendOrderConfirmationEmail(
                orderConfirmation.customer().email(),
                customerName,
                orderConfirmation.totalAmount(),
                orderConfirmation.orderReference(),
                orderConfirmation.products()
        );
    }

}

config.yml

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>
@Configuration
public class Config {
@Bean
public JavaMailSender javaMailSender() {
return new JavaMailSenderImpl();
}
}
</code>
<code> @Configuration public class Config { @Bean public JavaMailSender javaMailSender() { return new JavaMailSenderImpl(); } } </code>


@Configuration
public class Config {

    @Bean
    public JavaMailSender javaMailSender() {
        return new JavaMailSenderImpl();
    }

}

Not sure I may need additional setting for consumer or Bean

  1. Already checked the
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>spring.kafka.consumer.properties.spring.json.type.mapping
</code>
<code>spring.kafka.consumer.properties.spring.json.type.mapping </code>
spring.kafka.consumer.properties.spring.json.type.mapping 

and compare both class to make sure there is no attribute mismatch

  1. Already checkout producer and consumer’s application.yml key and value both serializer and deserializer setting

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật