Questions tagged [messagepack]

MessagePack is a binary-based efficient object serialization library. It enables to exchange structured objects between many languages like JSON. But unlike JSON, it is very fast and small.

http://msgpack.org/

MessagePack is a binary-based efficient object serialization library. It enables to exchange structured objects between many languages like JSON. But unlike JSON, it is very fast and small.

Typical small integer (like flags or error code) is saved only in 1 byte, and typical short string only needs 1 byte except the length of the string itself. [1,2,3] (3 elements array) is serialized in 4 bytes using MessagePack as follows:

> require 'msgpack'
> msg = [1,2,3].to_msgpack  #=> "\x93\x01\x02\x03"
> MessagePack.unpack(msg)   #=> [1,2,3]

Scalable RPC

MessagePack-RPC is cross-language RPC library for client, server and cluster applications. Because it releases you from complicated network programming completely and provides well-designed API, you can easily implement advanced network applications with MessagePack-RPC.

require 'msgpack/rpc'
class MyHandler
  def add(x,y) return x+y end
end
svr = MessagePack::RPC::Server.new
svr.listen('0.0.0.0', 18800, MyHandler.new)
svr.run

require 'msgpack/rpc'
c = MessagePack::RPC::Client.new('127.0.0.1',18800)
result = c.call(:add, 1, 2)  #=> 3

MessagePack is available for many languages:

  • C
  • C++
  • D
  • Erlang
  • Go
  • Haskell
  • Java
  • OCaml
  • Python
  • Perl
  • PHP
  • Ruby
  • Scala
72 questions
1
vote
1 answer

How to serialize JSON document using Messagepack (Cannot find template for class java.lang.Object)?

I am planning to use Messagepack in our project. Currently, we are using JSON in our project and we are writing serialize JSON document into Cassandra. Now we are thinking to use Messagepack which is an efficient binary serialization format. I am…
arsenal
  • 23,366
  • 85
  • 225
  • 331
1
vote
0 answers

MessagePack and Immutable Objects

I have many immutable domain objects with private final fields and public getter methods. Is it possible to serialize them using the MessagePack implementation for Java? I know the @Message annotation only supports public fields, but I was hoping…
dbyrne
  • 59,111
  • 13
  • 86
  • 103
1
vote
1 answer

Java msgpack class with floats crashes

I have a very simple java class that represents a 2d vector. Yet when I run the code to serialize it to message pack, it creates a runtime error. Serializing this class should be really basic behaviour and should work, right? I found no one else who…
0
votes
1 answer

MessagePack and Glassfish

I'm trying to use MessagePack in a WAR application in Glassfish, but I'm getting this exception (although JavaAssist already is a library of the project): java.lang.NoClassDefFoundError: javassist/ClassPath at …
SDReyes
  • 9,798
  • 16
  • 53
  • 92
0
votes
0 answers

How do I write a serializer in C using MessagePack (Mpack)

I would like to write a serializer application that will encode any type of C data structure into MessagePack format. All examples I have seen show the encoding of known structures such as this using MPack: // encode to memory buffer char*…
Koi
  • 105
  • 9
0
votes
1 answer

What is the difference between MessagePack, Protobuf and JSON ? Can anyone tell me which one to use when

I need to understand the difference between - message pack - protocol buffers - JSON
Kani
  • 25
  • 5
0
votes
1 answer

File byte error in kotlin. How to transfer correctly?

I want to Transfer file with tcp client to server, but image file has been wrong. My client code is import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream import org.msgpack.core.MessageBufferPacker import…
0
votes
1 answer

MessagePack RPC C# - Server side

I have a problem when trying to consume a server implementation of MessagePack RPC. I wrote one implementation for client and one for server based on a Python code provided by my company's client. The server implementation should be consumed by…
0
votes
1 answer

MsgPack Serialization in .Net 2.0

I want to use a fast Serialization for exchange byte data from .NET 2.0 application, .NET 4.0 application and Android application. Scheme The problem is that the NuGet MessagePack packet is only for .NET 4.0 and I can't serialize data whit the .NET…
Gabriele Feudo
  • 59
  • 1
  • 1
  • 9
0
votes
2 answers

Parsing json messagepack data in javascript

I'm sending json data to a websocketpp server with messagepack using kawanet/msgpack-lite (javascript) on the client and msgpack/msgpack-c (C++) to unpack it and nlohmann/json to parse it on the server. This goes fine. But I'm apparently using…
kometen
  • 6,536
  • 6
  • 41
  • 51
0
votes
1 answer

new to cpp , how do I run messagepack?

I am new to visual studio and c++ . I have downloaded MessagePack for c/cpp and opened the file "msgpack_vc8.vcproj" it opened a visual studio project with a bunch of c files and hpp file. now , I would like to see an example of how Message Pack…
yanish
  • 257
  • 2
  • 15
0
votes
2 answers

How does msgpack differ in perl from node.js

Does anyone have a clue why perl's MessagePack gives different results from that in Node.js . I am trying to unpack a msgpack string that was created using Perl's Message Pack and it doesn't work Example: Array ["a","b","c","d","f"] packing it in…
0
votes
1 answer

How do you convert a case class to a class?

I have a case class Person(name:String, id:Int) for serialization reasons (MessagePack), I need to convert this to a class. Is there an easy / elegant way to do this which does not require too much boilerplate or creation? case class…
user3335040
  • 649
  • 1
  • 7
  • 17
0
votes
1 answer

Message Pack : Do not convert System.Boolean (binary:0x0) MessagePackObject to System.Int64

We get following error while unpacking packed message to an object. This error is not noticed on local development environment (windows 7) but occurs in the server environment. (server 2008). System.Reflection.TargetInvocationException: Exception…
0
votes
1 answer

Ruby/Rack/Sinatra encoding of a MessagePack POST

I am trying to build an API with Sinatra and MessagePack but I am about to shoot myself :) So I am using curl to do a POST: curl -X POST -H "Content-Type: application/x-msgpack" --data-binary…
user287689