DEV Community


Sequelize belongstomany Example – Nodejs/Expresss

Software Engineer - Founder at
・2 min read

Sequelize belongstomany Example – Nodejs/Express

In the previous post, we had setup a Spring Kafka Application succesfully by explicitly configuration Kafka Factories with SpringBoot. But the messages had been used have String type. While in the development, POJO (Plain Old Java Object) are often used to construct messages. So with the tutorial, JavaSampleApproach will show how to use Spring Kafka JsonSerializer (JsonDeserializer) to produce/consume Java Object messages.

Related articles:

I. Technologies

– Java 8
– Maven build
– Spring Boot
– Apache Kafka
– Spring Tool Suite editor

II. Overview

Spring Kafka Application - architecture

In the tutorial, we send and receive Java object messages to/from Apache Kafka, so ProducerFactory uses JsonSerializer.class and ConsumerFactory uses JsonDeserializer.class to serialize/deserialize Java objects to Json bytes.

  • KafkaProducerConfig:

public ProducerFactory producerFactory() {
    configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class);
    return new DefaultKafkaProducerFactory<>(configProps);
public KafkaTemplate kafkaTemplate() {
    return new KafkaTemplate<>(producerFactory());
  • KafkaConsumerConfig:

Sequelize belongstomany Example – Nodejs/Express

Discussion (0)

Forem Open with the Forem app