Eclipse Kapua :: Gateway Client :: Features :: Karaf (Examples)

A gateway client SDK for Eclipse Kapua™

License

License

GroupId

GroupId

de.dentrassi.kapua
ArtifactId

ArtifactId

karaf-examples
Last Version

Last Version

0.2.1
Release Date

Release Date

Type

Type

xml
Description

Description

Eclipse Kapua :: Gateway Client :: Features :: Karaf (Examples)
A gateway client SDK for Eclipse Kapua™

Download karaf-examples

Dependencies

compile (1)

Group / Artifact Type Version
de.dentrassi.kapua.examples : eclipse-smarthome-persistence jar 0.2.1

provided (5)

Group / Artifact Type Version
org.apache.karaf.features : framework kar 4.1.1
org.apache.karaf.features : standard xml 4.1.1
org.eclipse.smarthome » esh-tp xml 0.9.0.b4
org.eclipse.smarthome » esh-core xml 0.9.0.b4
de.dentrassi.kapua : karaf xml 0.2.1

Project Modules

There are no modules declared in this project.

Eclipse Kapua™ Gateway Client SDK Build status Maven Central

This project provides an SDK for connecting to Eclipse Kapua as a gateway.

Note: This is not part of the Eclipse Kapua project.

This project should provide a simple to use SDK for pushing telemetry data into Kapua and consuming command messages out of Kapua.

Note: This is a work in progress and should not be considered production ready.

How to use

The following quick steps should provide you with a working example.

Add to your Maven project

<dependency>
  <groupId>de.dentrassi.kapua</groupId>
  <artifactId>kapua-gateway-client-provider-mqtt-fuse</artifactId>
  <version><!-- replace with current version --></version>
</dependency>
<dependency>
  <groupId>de.dentrassi.kapua</groupId>
  <artifactId>kapua-gateway-client-profile-kura</artifactId>
  <version><!-- replace with current version --></version>
</dependency>

Example client

import static org.eclipse.kapua.gateway.client.Credentials.userAndPassword;
import static org.eclipse.kapua.gateway.client.Errors.ignore;

import org.eclipse.kapua.gateway.client.mqtt.fuse.FuseClient;
import org.eclipse.kapua.gateway.client.profile.kura.KuraMqttProfile;

try (Client client = KuraMqttProfile.newProfile(FuseClient.Builder::new)
  .accountName("kapua-sys")
  .clientId("foo-bar-1")
  .brokerUrl("tcp://localhost:1883")
  .credentials(userAndPassword("kapua-broker", "kapua-password"))
  .build()) {

  try (Application application = client.buildApplication("app1").build()) {

    // subscribe to a topic

    application.data(Topic.of("my", "receiver")).subscribe(message -> {
      System.out.format("Received: %s%n", message);
    });

    // cache sender instance

    Sender<RuntimeException> sender = application
      .data(Topic.of("my", "sender"))
      .errors(ignore());

    int i = 0;
    while (true) {
      // send
      sender.send(Payload.of("counter", i++));
      Thread.sleep(1000);
    }
  }
}

Versions

Version
0.2.1
0.2.0