Skip to content

Repository files navigation

OpenBMP API Message Java Library

This library implements the OpenBMP message bus specification as defined at MESSAGE_BUS_API.md.

Messages from kafka (headers and content) are parsed and made available in Map and String/JSON. ObjectMapper can be used to convert to POJO.

Current Schema supported is 1.2

Install

Currently this is not in maven central, but will be soon. For now, you should do a maven install into your local repository.

git clone cd openbmp-api-message
mvn clean install

You can also do a maven clean package to create the jar file.

Usage

Use this library in any existing java project.

Maven

 <dependency>
<groupId>org.openbmp.api</groupId>
<artifactId>openbmp-api-message</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>

Code

importorg.openbmp.api.parsed.message.*;
Stringraw_kafka_message_data;
Messagemsg = newMessage(raw_kafka_message_data);
// Parse the content data by its typePeerpeer = newPeer(msg.getContent());
// Do something with peer.getRowMap() or peer.toJson()

Message

Normally the first thing to do is parse the raw Kafka received message by using the Message class. This class will parse the headers and content data.

Message Specific Classes

Each message type, such as Router, Peer, ... are parsed based on MESSAGE_BUS_API.md. This is why there is a separate class for each type. All classes return the same data for use by your application.

/** * Get the rowMap * * @return parsed rowMap is returned */publicList<Map<String, Object>> getRowMap();
/** * Get rowMap as Json * * @return JSON String representing the parsed rowMap */publicStringtoJson();
/** * Get rowMap as Pretty Json * * @return Pretty formatted JSON String representing the parsed rowMap */publicStringtoJsonPretty();
}

Spring Cloud-Stream

Spring Cloud-Stream is very easy to use with Kafka and OpenBMP.
See example spring-cloud-stream-sink for a working example.

About

OpenBMP Java Deserialization of messages from Collector

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages