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
avsc
module withnpm install avsc --save
command.
MsgPack serializer
Built-in MsgPack serializer.
const broker = new ServiceBroker({ |
DependenciesTo use this serializer install the
msgpack5
module withnpm install msgpack5 --save
command.
ProtoBuf serializer
Built-in Protocol Buffer serializer.
const broker = new ServiceBroker({ |
DependenciesTo use this serializer install the
protobufjs
module withnpm install protobufjs --save
command.
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"); |