Transporter needs a serializer module which serializes & deserializes the transferred packets.
Example
const { ServiceBroker } = require("moleculer"); |
Built-in serializers
JSON serializer
This is the built-in default serializer. It serializes the packets to JSON string and deserializes the received data to packet.
const broker = new ServiceBroker({ |
Avro serializer
Built-in Avro serializer.
const broker = new ServiceBroker({ |
DependenciesTo use this serializer install the
avscmodule withnpm install avsc --savecommand.
MsgPack serializer
Built-in MsgPack serializer.
const broker = new ServiceBroker({ |
DependenciesTo use this serializer install the
msgpack5module withnpm install msgpack5 --savecommand.
ProtoBuf serializer
Built-in Protocol Buffer serializer.
const broker = new ServiceBroker({ |
DependenciesTo use this serializer install the
protobufjsmodule withnpm install protobufjs --savecommand.
Custom serializer
You can also create your custom serializer module. We recommend to copy the source of JSONSerializer and implement the serialize and deserialize methods.
Use custom serializer
const { ServiceBroker } = require("moleculer"); |