MessagePack Tutorial with Spring Boot

It’s like JSON but fast and small. That is how MessagePack is described by MessagePack. It has an easy setup and usage. Decoding for a single operation is faster than JSON about 1 ms. We can get benefit from MsssagPack especially when we are working with microservices Redis, FluentD and Pinterest are the famous companies that use MessagePack. From their homepage, compact = true and schema = 0 are the entries they use for benchmarking. Json encoded version is 27 bytes while MessagePack encoded version is 18 bytes. It has also huge support for programming languages. But migrating from JSON to message pack we have to be careful as every application has different conditions and challenges. So we have to see the test results before giving any decisions.

We are going to create a simple tutorial for MessagePack with Spring Boot. We create a RESTful Web Service application. We add the dependencies to our pom.xml.


We create a Student class with Lombok. If you are using the IntelliJ idea and you can add the Lombok plugin from the settings-plugins menu.

Student class

We create our RestController. The Bean injection converts the message, with response type “application”, “x-msgpack”. We have created a simple student list.

MsgController class

When we click the URL … /students you will see a file downloading. But it is not human readable. To read the data we will use the …/msgpack URL.

Output for (http://localhost:7815/msgpack)

Thanks for reading. The source file for our tutorial can be found on GitHub



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store