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

arp.message.rocketmq.FSTSerializationStrategy Maven / Gradle / Ivy

There is a newer version: 1.0.3
Show newest version
package arp.message.rocketmq;

import arp.process.publish.Message;
import org.nustaq.serialization.FSTConfiguration;
import org.nustaq.serialization.FSTObjectOutput;

import java.io.ByteArrayOutputStream;

public class FSTSerializationStrategy implements
        RocketmqMessageSerializationStrategy {

    private FSTConfiguration fstConf;

    public FSTSerializationStrategy() {
        fstConf = FSTConfiguration.createJsonConfiguration();
        fstConf.setForceSerializable(true);
    }


    @Override
    public byte[] serialize(Message message) throws Exception {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        FSTObjectOutput oos = fstConf.getObjectOutput(bos);
        oos.writeObject(message);
        oos.flush();
        return bos.toByteArray();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy