All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mq.aliyun.example.producers.MyProducerSerialize Maven / Gradle / Ivy

The newest version!
package com.mq.aliyun.example.producers;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.mq.producer.ProducerSerialize;

/**
 * Created by wangziqing on 17/7/25.
 */
public class MyProducerSerialize implements ProducerSerialize {

    private static final ObjectMapper mapper = new ObjectMapper();

    @Override
    public byte[] objToBytes(Object object) {
        //do some thine
        try {
            return mapper.writeValueAsBytes(object);
        } catch (JsonProcessingException e) {
            e.printStackTrace();

            throw new RuntimeException("序列化失败");
        }

    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy