package com.example;

import com.fasterxml.jackson.core.JsonProcessingException;
import org.apache.kafka.common.errors.SerializationException;
import org.apache.kafka.common.serialization.Serializer;

import java.nio.charset.StandardCharsets;

public class TransactionInfoSerializer implements Serializer<TransactionInfo> {
    @Override
    public byte[] serialize(String topic, TransactionInfo data) {
        try {
            return MyProducer.objectMapper.writeValueAsBytes(data);
        } catch (JsonProcessingException e) {
            throw new SerializationException("Error serializing TransactionInfo", e);
        }
    }
}
