Bauer (a.k.a. stf4j - Simple Topic Facade for Java) serves as a simple facade or abstraction for various topic-based message-queues systems, such as Kafka, FFMQ, Java Message Service and MQTT. Bauer allows the end-user to plug in the desired message-queue framework at deployment time. Note that Bauer-enabling your library/application implies the addition of only a single mandatory dependency, namely bauer-api.jar.
Bauer has been written with esteem and respect for slf4j, the world famous Simple Logging Facade for Java.
#!xml
<dependency>
<groupId>it.netgrid</groupId>
<artifactId>bauer-api</artifactId>
<version>0.0.15-SNAPSHOT</version>
</dependency>
#!java
Topic<MyCustomPayload> myCustomTopic = TopicFactory.getTopic("/my/topic/path");
myCustomTopic.post(new MyCustomPayload("Hello World"));
#!java
Topic<MyCustomPayload> myCustomTopic = TopicFactory.getTopic("/my/topic/path");
myCustomTopic.addHandler(new EventHandler<MyCustomPayload>() {
@Override
public Class<MyCustomPayload> getEventClass() {
return MyCustomPayload.class;
}
@Override
public String getName() {
return "handler-identifier";
}
@Override
public boolean handle(String topic, MyCustomPayload event) {
System.out.println(event.getMyCustomProperty())
return true;
}
});
As mentioned previously, Bauer supports various topic-based event-queues frameworks. Some of them still in development. The Bauer distribution ships with serveral jar files referred as "Bauer bindings", with each binding corresponding to a supported framework.
Binding for FFMQ 4.0.14, a JMS compatible ultra-light weight message queue system.
Binding for MQTT, a M2M/Internet-of-Things connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport.
Binding for Apache Kafka, a distributed streaming platform. Kafka is run as a cluster on one or more servers. Ideal for real-time streaming data pipelines that reliably get data between systems or applications.
To switch event-queue framework, just replace Bauer bindings on your class path. For example, to switch from FFMQ to Kafka, just replace bauer-ffmq with bauer-kafka.
Bauer does not rely on any special class loader machinery. In fact, each Bauer binding is hardwired at compile time to use one and only one specific event-queue framework. In your code, in addition to bauer-api, you simply drop one and only one binding of your choice onto the appropriate class path location. Do not place more than one binding on your class path.
Bauer relies upon three core concepts: events, topics and event handlers.
An event is a batch of data.
A topic is a stream of events of the same kind, sent at different times from different sources.
Piece of code executed each time a new event occurs in the topic which holds the code
By default, bauer-ffmq (JMS) uses JSON for events de/serialization. We choose JSON interoperability over binary efficiency. Bauer-MQTT uses CBOR for events de/serialization.
you need access to https://oss.sonatype.org/
check your ~/.m2/settings.xml
<settings>
<servers>
<server>
<id>ossrh</id>
<username>USERNAME</username>
<password>PASSWORD</password>
</server>
</servers>
</settings>
then run in repo
mvn deploy