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.
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.
Use this library in any existing java project.
<dependency>
<groupId>org.openbmp.api</groupId>
<artifactId>openbmp-api-message</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>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()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.
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 is very easy to use with Kafka and OpenBMP.
See example spring-cloud-stream-sink for a working example.