So far we've been using JSON to serialize our messages. "Serialization" is a fancy way to say "convert our struct into a format to be sent over the network". JSON is often a great choice because it's human-readable, easy to work with, and widely supported.
When you run into a problem, you can view the raw message in the Rabbit UI and read it. However, AMQP doesn't require you to use JSON, it works with raw bytes.
JSON isn't the most efficient way to serialize data, so when you're sending massive amounts of data, you might want to consider a more efficient format.
With TypeScript, we can use MessagePack to serialize our data. MessagePack is a binary format that is more efficient than JSON. It's faster to encode and decode, and it uses less space.
MessagePack is a binary format, so it's not human-readable. However, it is widely supported in many programming languages
npm install @msgpack/msgpack
export function publishMsgPack<T>(
ch: ConfirmChannel,
exchange: string,
routingKey: string,
value: T,
): Promise<void>;
Become a member to Complete
Become a member to view solution