Annotation Interface BabelIPMessage
Annotation that marks a Java
record as a Babel IP network message and assigns it a
unique integer identifier used during serialization and deserialization.
At compile time the babel2-ip-compiler annotation processor detects every type
annotated with @BabelIPMessage and generates a corresponding
BabelNetworkMessageSerializer
implementation that handles binary encoding of all record components. The generated serializer
is registered via the Java ServiceLoader mechanism so that it is automatically
discovered by
SerializerRegistry at runtime.
The annotated type must be a record; applying this annotation to a
class or interface will cause a compile-time error.
Each message type must have a globally unique id value. Duplicate IDs across
different message types will be detected at class-loading time and cause a
MessagesWithSameIdException to be
thrown.
Example usage:
@BabelIPMessage(id = 42)
public record PingMessage(UUID sender, int sequenceNumber) implements BabelMessage {}
-
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionintThe unique integer identifier for this message type.
-
Element Details
-
id
int idThe unique integer identifier for this message type. This value is written to the wire immediately after the Babel magic number so that the receiving side can look up the correct deserializer. The value must be unique across all message types registered in the same JVM.- Returns:
- the numeric message identifier
-