Java

The KubeMQ SDK for Java enables Java developers to easily work with KubeMQ server.

Table of Content

General SDK description

The SDK implements all communication patterns available through the KubeMQ server:

  • Events
  • EventStore
  • Command
  • Query

Prerequisites

KubeMQ-SDK-Java works with JDK 8+.

Installing

The recommended way to use the SDK for Java in your project is to consume it from Maven.

<dependency>
  <groupId>io.kubemq</groupId>
  <artifactId>kubemq-java-sdk-bom</artifactId>
  <version>1.0.1</version>
  <type>pom</type>
  <scope>import</scope>
</dependency>
1
2
3
4
5
6
7

To build with Gradle, add the dependency below to your build.gradle file.

compile group: 'io.kubemq.sdk', name: 'kubemq-java-sdk', version: '1.0.1'
1

Configurations

The only required configuration setting is the KubeMQ server address.

Configuration can be set by using one of the following:

  • Environment Variable
  • 'Java Property'

Configuration via Environment Variable

Set KubeMQServerAddress to the KubeMQ Server Address

Configuration via Java Property

by passing the -DKubeMQServerAddress= option to the JVM) Within the code

Configuration via code

When setting the KubeMQ server address within the code, simply pass the address as a parameter to the various constructors. See exactly how in the code examples in this document.

Generating Documentation

Javadoc is used for documentation. You can generate HTML locally with the following:

.gradlew javadoc
1

Running the examples

The examples are standalone projects that showcase the usage of the SDK.

To run the examples, you need to have a running instance of KubeMQ.

You can use the Gradle tasks to run the examples:

.gradlew commandQueryChannel
.gradlew commandQueryInitiator
.gradlew commandQueryResponder
.gradlew commandQueryResponderAsync
.gradlew eventChannel
.gradlew eventSender
.gradlew eventSubscriber
1
2
3
4
5
6
7

Building from source

Once you check out the code from GitHub, you can build it using Gradle.

.gradlew build
1

Running the tests

To run the automated tests for this system execute:

.gradlew test
1
Last Updated: 7/23/2019, 7:38:09 PM