com.jukusoft:vertx-binary-serializer-benchmark

A simple binary serialization method for vertx which uses annotations and reflection like spring jpa / hibernate for databases.

License

License

GroupId

GroupId

com.jukusoft
ArtifactId

ArtifactId

vertx-binary-serializer-benchmark
Last Version

Last Version

1.0.5
Release Date

Release Date

Type

Type

jar
Description

Description

A simple binary serialization method for vertx which uses annotations and reflection like spring jpa / hibernate for databases.

Download vertx-binary-serializer-benchmark

How to add to project

<!-- https://jarcasting.com/artifacts/com.jukusoft/vertx-binary-serializer-benchmark/ -->
<dependency>
    <groupId>com.jukusoft</groupId>
    <artifactId>vertx-binary-serializer-benchmark</artifactId>
    <version>1.0.5</version>
</dependency>
// https://jarcasting.com/artifacts/com.jukusoft/vertx-binary-serializer-benchmark/
implementation 'com.jukusoft:vertx-binary-serializer-benchmark:1.0.5'
// https://jarcasting.com/artifacts/com.jukusoft/vertx-binary-serializer-benchmark/
implementation ("com.jukusoft:vertx-binary-serializer-benchmark:1.0.5")
'com.jukusoft:vertx-binary-serializer-benchmark:jar:1.0.5'
<dependency org="com.jukusoft" name="vertx-binary-serializer-benchmark" rev="1.0.5">
  <artifact name="vertx-binary-serializer-benchmark" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.jukusoft', module='vertx-binary-serializer-benchmark', version='1.0.5')
)
libraryDependencies += "com.jukusoft" % "vertx-binary-serializer-benchmark" % "1.0.5"
[com.jukusoft/vertx-binary-serializer-benchmark "1.0.5"]

Dependencies

compile (4)

Group / Artifact Type Version
com.jukusoft : vertx-binary-serializer jar 1.0.5
com.carrotsearch : hppc jar 0.8.1
org.javolution : javolution-core-java jar 6.0.0
io.vertx : vertx-core jar 3.5.4

test (3)

Group / Artifact Type Version
junit : junit jar 4.12
io.vertx : vertx-unit jar 3.5.4
org.mockito : mockito-core jar 2.2.7

Project Modules

There are no modules declared in this project.

vertx-binary-serialization

A simple binary serialization method for vertx which uses annotations & reflection like spring jpa for databases.

Build Status Lines of Code Quality Gate Coverage Technical Debt Rating Code Smells Bugs Vulnerabilities Security Rating

Sonarcloud

Requirements

Maven Coordinates

Maven Central

<dependency>
  <groupId>com.jukusoft</groupId>
  <artifactId>vertx-binary-serializer</artifactId>
  <version>1.0.8</version>
</dependency>

<!-- If you want to use TCPServer and TCPClient, you need also this dependency -->
<dependency>
  <groupId>com.jukusoft</groupId>
  <artifactId>vertx-binary-serializer-connection</artifactId>
  <version>1.0.8</version>
</dependency>

HowTo

First create some message objects which contains some datatypes:

@MessageType(type = 0x01)
@ProtocolVersion(1)
public class Message implements SerializableObject {

    @SInteger
    public int test = 0;

}

@MessageType(type = 0x02)
@ProtocolVersion(2)
public class SecondMessage implements SerializableObject {
    
    @SFloat
    public float a = 0f;

    @SString
    public String myString = null;

}

You have to add the annotations MessageType with the type (1 byte as type, 1 byte as extended type) and ProtocolVersion to check, if Serializer on other side can unserialize this object.

Then you can serialize and unserialize this object easely:

//first, register this new message types
TypeLookup.register(Message.class);
TypeLookup.register(SecondMessage.class);

//create message object which implements SerializableObject
Message msg = new Message();
msg.test = 20;

SecondMessage msg1 = new SecondMessage();
msg1.a = 0.2f;
msg1.myString = "my-new-string";

//serialize object into byte buffer
Buffer buffer = Serializer.serialize(msg);

//unserialize object from byte buffer
Message obj1 = Serializer.unserialize(buffer);

//get value
System.out.println("test value: " + obj1.test);

//second message

//serialize object into byte buffer
Buffer buffer = Serializer.serialize(msg1);

//unserialize object from byte buffer
SecondMessage obj2 = Serializer.unserialize(buffer);

//get value(s)
System.out.println("float value: " + obj2.a);
System.out.println("string value: " + obj2.myString);

NOTICE: public variables aren't required, they can also be private or protected instead. But to avoid getters & setters here, we have accessed them directly in this example.

Protocol Header

Before adding the payload to buffer, there is adding a header with these fields:

  • maybe: 4x byte (integer) length of message (so it can check, if full message was received or we have to wait for other traffic)
  • 1x byte type
  • 1x byte extended byte (so you can use 65,536 different types, instead of 256 bytes)
  • 2x byte version (to check compatibility)
  • after that: payload data

Supported datatypes

All primitive datatypes in Java are supported:

  • byte (@SByte)
  • short (@SShort)
  • int (@SInteger)
  • long (@SLong)
  • float (@SFloat)
  • double (@SDouble)
  • boolean (@SBoolean)
  • char (@SChar)
  • Vertx. Buffer (@SBuffer)
  • byte array (max 4.294.967.296 bytes in an array, @SBytes)
  • json object & json array (@SJsonObject and @SJsonArray)

Complex datatypes (objects) are not supported!

Run Sonarcloud

clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=jukusoft -Dsonar.login=<Sonar-Token>

Support

If you have questions, found a bug or have a feature request:
Please open an issue! I try to answer as fast as possible.

Versions

Version
1.0.5
1.0.4
1.0.3
1.0.2
1.0.0