How to serialize in .NET MessagePack and deserialize in Node.jsHow do I enumerate an enum in C#?How do I debug Node.js applications?How do I get started with Node.js.NET - JSON serialization of enum as stringWriting files in Node.jsHow do I pass command line arguments to a Node.js program?Read environment variables in Node.jsHow to decide when to use Node.js?How to exit in Node.jsWhat is the purpose of Node.js module.exports and how do you use it?
Course development: can I pay someone to make slides for the course?
Have minipage take up entire page height
If absolute velocity does not exist, how can we say a rocket accelerates in empty space?
Noblesse oblige loanword in German
Why is it bad to use your whole foot in rock climbing
Create a cube from identical 3D objects
Is it advisable to add a location heads-up when a scene changes in a novel?
How to make a composition of functions prettier?
Do Veracrypt encrypted volumes have any kind of brute force protection?
What does the homotopy coherent nerve do to spaces of enriched functors?
After an 87 day stay in the USA, can I return for a long weekend? (ESTA)
Placement of positioning lights on A320 winglets
How do I make a Magical Dart Thrower more economical in Adventurers League?
What's the difference between DHCP and NAT? Are they mutually exclusive?
Was planting UN flag on Moon ever discussed?
What do you call the action of "describing events as they happen" like sports anchors do?
Are the guests in Westworld forbidden to tell the hosts that they are robots?
Do SFDX commands count toward limits?
What is the interaction between Muraganda Petroglyphs and Humility?
How to Convert an Object into Array in magento 2
In The Incredibles 2, why does Screenslaver's name use a pun on something that doesn't exist in the 1950s pastiche?
How to avoid typing 'git' at the begining of every Git command
Parsing text written the millitext font
What is the proper event in Extended Events to track stored procedure executions?
How to serialize in .NET MessagePack and deserialize in Node.js
How do I enumerate an enum in C#?How do I debug Node.js applications?How do I get started with Node.js.NET - JSON serialization of enum as stringWriting files in Node.jsHow do I pass command line arguments to a Node.js program?Read environment variables in Node.jsHow to decide when to use Node.js?How to exit in Node.jsWhat is the purpose of Node.js module.exports and how do you use it?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have a RabbitMQ queue and two applications. First application is written in .NET core to generate send the payload to queue and the second one is in Node.js to read from the queue.
Producer Application
I use MessagePack-CSharp to serialize and compress (LZ4) the payload. Here is the serialization code in .NET:
using MessagePack;
namespace uBeac.Serialization
public class MessageSerilizer
public static byte[] Serialize(object message)
MessagePackSerializer.SetDefaultResolver(MessagePack.Resolvers.ContractlessStandardResolver.Instance);
return LZ4MessagePackSerializer.Serialize(message);
Consumer Application
I am reading the bytes in Node.js using amqplib library as below:
var amqp = require('amqplib/callback_api');
amqp.connect('amqp://...................', function (err, conn)
conn.createChannel(function (err, ch)
var queueName = 'toProcessor';
ch.assertQueue(queueName, durable: false );
ch.prefetch(1);
console.log(" [*] Waiting for messages in %s. To exit press CTRL+C", queueName);
ch.consume(queueName, function (msg)
var secs = msg.content.toString().split('.').length - 1;
console.log(" [x] Received %s", msg.content.toString());
setTimeout(function ()
console.log(" [x] Done");
ch.ack(msg);
, secs * 1000);
, noAck: false );
);
);
I have tried to deserialize the payload to Json object using some MsgPack libraries like messagepack, msgpack-node, ... But, it seems that they don't provide the same library in .NET as I showed above.
Question: How can I decompress and deserialize the payload to Json object?
c# node.js msgpack lz4
|
show 2 more comments
I have a RabbitMQ queue and two applications. First application is written in .NET core to generate send the payload to queue and the second one is in Node.js to read from the queue.
Producer Application
I use MessagePack-CSharp to serialize and compress (LZ4) the payload. Here is the serialization code in .NET:
using MessagePack;
namespace uBeac.Serialization
public class MessageSerilizer
public static byte[] Serialize(object message)
MessagePackSerializer.SetDefaultResolver(MessagePack.Resolvers.ContractlessStandardResolver.Instance);
return LZ4MessagePackSerializer.Serialize(message);
Consumer Application
I am reading the bytes in Node.js using amqplib library as below:
var amqp = require('amqplib/callback_api');
amqp.connect('amqp://...................', function (err, conn)
conn.createChannel(function (err, ch)
var queueName = 'toProcessor';
ch.assertQueue(queueName, durable: false );
ch.prefetch(1);
console.log(" [*] Waiting for messages in %s. To exit press CTRL+C", queueName);
ch.consume(queueName, function (msg)
var secs = msg.content.toString().split('.').length - 1;
console.log(" [x] Received %s", msg.content.toString());
setTimeout(function ()
console.log(" [x] Done");
ch.ack(msg);
, secs * 1000);
, noAck: false );
);
);
I have tried to deserialize the payload to Json object using some MsgPack libraries like messagepack, msgpack-node, ... But, it seems that they don't provide the same library in .NET as I showed above.
Question: How can I decompress and deserialize the payload to Json object?
c# node.js msgpack lz4
If you are compressing to LZ4 as a binary stream, what makes you think you can deserialise it via a JSON library?
– MickyD
Mar 24 at 23:20
@MickyD I tried to so that using #lz4js: lz4.decompress(msg.content) , but it throws throw er; // Unhandled 'error' event
– Amir Pournasserian
Mar 24 at 23:26
Then maybe better to fix that error than trying something that may not work at all?
– MickyD
Mar 24 at 23:29
1
YourProduceris clearly serializing in binary and yourConsumerdeserializing as string. That's not going to work. My advice is to follow general enterprise messaging best practices and have your message content astextand not binary, therefore no explicit manual compression in the content. Binary encoding places certain assumptions on the part of the receiver and reduces your audience not to mention you are more than likely going to break consumers with future changes. Now if it istextyou are not locked to any one vendor to encode/decode objects.
– MickyD
Mar 24 at 23:53
1
Serialize astext. Whether that is XML; JSON or something else is up to you
– MickyD
Mar 25 at 0:38
|
show 2 more comments
I have a RabbitMQ queue and two applications. First application is written in .NET core to generate send the payload to queue and the second one is in Node.js to read from the queue.
Producer Application
I use MessagePack-CSharp to serialize and compress (LZ4) the payload. Here is the serialization code in .NET:
using MessagePack;
namespace uBeac.Serialization
public class MessageSerilizer
public static byte[] Serialize(object message)
MessagePackSerializer.SetDefaultResolver(MessagePack.Resolvers.ContractlessStandardResolver.Instance);
return LZ4MessagePackSerializer.Serialize(message);
Consumer Application
I am reading the bytes in Node.js using amqplib library as below:
var amqp = require('amqplib/callback_api');
amqp.connect('amqp://...................', function (err, conn)
conn.createChannel(function (err, ch)
var queueName = 'toProcessor';
ch.assertQueue(queueName, durable: false );
ch.prefetch(1);
console.log(" [*] Waiting for messages in %s. To exit press CTRL+C", queueName);
ch.consume(queueName, function (msg)
var secs = msg.content.toString().split('.').length - 1;
console.log(" [x] Received %s", msg.content.toString());
setTimeout(function ()
console.log(" [x] Done");
ch.ack(msg);
, secs * 1000);
, noAck: false );
);
);
I have tried to deserialize the payload to Json object using some MsgPack libraries like messagepack, msgpack-node, ... But, it seems that they don't provide the same library in .NET as I showed above.
Question: How can I decompress and deserialize the payload to Json object?
c# node.js msgpack lz4
I have a RabbitMQ queue and two applications. First application is written in .NET core to generate send the payload to queue and the second one is in Node.js to read from the queue.
Producer Application
I use MessagePack-CSharp to serialize and compress (LZ4) the payload. Here is the serialization code in .NET:
using MessagePack;
namespace uBeac.Serialization
public class MessageSerilizer
public static byte[] Serialize(object message)
MessagePackSerializer.SetDefaultResolver(MessagePack.Resolvers.ContractlessStandardResolver.Instance);
return LZ4MessagePackSerializer.Serialize(message);
Consumer Application
I am reading the bytes in Node.js using amqplib library as below:
var amqp = require('amqplib/callback_api');
amqp.connect('amqp://...................', function (err, conn)
conn.createChannel(function (err, ch)
var queueName = 'toProcessor';
ch.assertQueue(queueName, durable: false );
ch.prefetch(1);
console.log(" [*] Waiting for messages in %s. To exit press CTRL+C", queueName);
ch.consume(queueName, function (msg)
var secs = msg.content.toString().split('.').length - 1;
console.log(" [x] Received %s", msg.content.toString());
setTimeout(function ()
console.log(" [x] Done");
ch.ack(msg);
, secs * 1000);
, noAck: false );
);
);
I have tried to deserialize the payload to Json object using some MsgPack libraries like messagepack, msgpack-node, ... But, it seems that they don't provide the same library in .NET as I showed above.
Question: How can I decompress and deserialize the payload to Json object?
c# node.js msgpack lz4
c# node.js msgpack lz4
edited Mar 24 at 23:13
MickyD
11.3k63454
11.3k63454
asked Mar 24 at 23:02
Amir PournasserianAmir Pournasserian
83031437
83031437
If you are compressing to LZ4 as a binary stream, what makes you think you can deserialise it via a JSON library?
– MickyD
Mar 24 at 23:20
@MickyD I tried to so that using #lz4js: lz4.decompress(msg.content) , but it throws throw er; // Unhandled 'error' event
– Amir Pournasserian
Mar 24 at 23:26
Then maybe better to fix that error than trying something that may not work at all?
– MickyD
Mar 24 at 23:29
1
YourProduceris clearly serializing in binary and yourConsumerdeserializing as string. That's not going to work. My advice is to follow general enterprise messaging best practices and have your message content astextand not binary, therefore no explicit manual compression in the content. Binary encoding places certain assumptions on the part of the receiver and reduces your audience not to mention you are more than likely going to break consumers with future changes. Now if it istextyou are not locked to any one vendor to encode/decode objects.
– MickyD
Mar 24 at 23:53
1
Serialize astext. Whether that is XML; JSON or something else is up to you
– MickyD
Mar 25 at 0:38
|
show 2 more comments
If you are compressing to LZ4 as a binary stream, what makes you think you can deserialise it via a JSON library?
– MickyD
Mar 24 at 23:20
@MickyD I tried to so that using #lz4js: lz4.decompress(msg.content) , but it throws throw er; // Unhandled 'error' event
– Amir Pournasserian
Mar 24 at 23:26
Then maybe better to fix that error than trying something that may not work at all?
– MickyD
Mar 24 at 23:29
1
YourProduceris clearly serializing in binary and yourConsumerdeserializing as string. That's not going to work. My advice is to follow general enterprise messaging best practices and have your message content astextand not binary, therefore no explicit manual compression in the content. Binary encoding places certain assumptions on the part of the receiver and reduces your audience not to mention you are more than likely going to break consumers with future changes. Now if it istextyou are not locked to any one vendor to encode/decode objects.
– MickyD
Mar 24 at 23:53
1
Serialize astext. Whether that is XML; JSON or something else is up to you
– MickyD
Mar 25 at 0:38
If you are compressing to LZ4 as a binary stream, what makes you think you can deserialise it via a JSON library?
– MickyD
Mar 24 at 23:20
If you are compressing to LZ4 as a binary stream, what makes you think you can deserialise it via a JSON library?
– MickyD
Mar 24 at 23:20
@MickyD I tried to so that using #lz4js: lz4.decompress(msg.content) , but it throws throw er; // Unhandled 'error' event
– Amir Pournasserian
Mar 24 at 23:26
@MickyD I tried to so that using #lz4js: lz4.decompress(msg.content) , but it throws throw er; // Unhandled 'error' event
– Amir Pournasserian
Mar 24 at 23:26
Then maybe better to fix that error than trying something that may not work at all?
– MickyD
Mar 24 at 23:29
Then maybe better to fix that error than trying something that may not work at all?
– MickyD
Mar 24 at 23:29
1
1
Your
Producer is clearly serializing in binary and your Consumer deserializing as string. That's not going to work. My advice is to follow general enterprise messaging best practices and have your message content as text and not binary, therefore no explicit manual compression in the content. Binary encoding places certain assumptions on the part of the receiver and reduces your audience not to mention you are more than likely going to break consumers with future changes. Now if it is text you are not locked to any one vendor to encode/decode objects.– MickyD
Mar 24 at 23:53
Your
Producer is clearly serializing in binary and your Consumer deserializing as string. That's not going to work. My advice is to follow general enterprise messaging best practices and have your message content as text and not binary, therefore no explicit manual compression in the content. Binary encoding places certain assumptions on the part of the receiver and reduces your audience not to mention you are more than likely going to break consumers with future changes. Now if it is text you are not locked to any one vendor to encode/decode objects.– MickyD
Mar 24 at 23:53
1
1
Serialize as
text. Whether that is XML; JSON or something else is up to you– MickyD
Mar 25 at 0:38
Serialize as
text. Whether that is XML; JSON or something else is up to you– MickyD
Mar 25 at 0:38
|
show 2 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55329418%2fhow-to-serialize-in-net-messagepack-and-deserialize-in-node-js%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55329418%2fhow-to-serialize-in-net-messagepack-and-deserialize-in-node-js%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If you are compressing to LZ4 as a binary stream, what makes you think you can deserialise it via a JSON library?
– MickyD
Mar 24 at 23:20
@MickyD I tried to so that using #lz4js: lz4.decompress(msg.content) , but it throws throw er; // Unhandled 'error' event
– Amir Pournasserian
Mar 24 at 23:26
Then maybe better to fix that error than trying something that may not work at all?
– MickyD
Mar 24 at 23:29
1
Your
Produceris clearly serializing in binary and yourConsumerdeserializing as string. That's not going to work. My advice is to follow general enterprise messaging best practices and have your message content astextand not binary, therefore no explicit manual compression in the content. Binary encoding places certain assumptions on the part of the receiver and reduces your audience not to mention you are more than likely going to break consumers with future changes. Now if it istextyou are not locked to any one vendor to encode/decode objects.– MickyD
Mar 24 at 23:53
1
Serialize as
text. Whether that is XML; JSON or something else is up to you– MickyD
Mar 25 at 0:38