pyroclast-java

Java SDK for Pyroclast

License

License

MIT
Categories

Categories

Java Languages
GroupId

GroupId

io.pyroclast
ArtifactId

ArtifactId

pyroclast-java
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

pyroclast-java
Java SDK for Pyroclast
Project URL

Project URL

https://github.com/pyroclastio/pyroclast-java
Source Code Management

Source Code Management

https://github.com/PyroclastIO/pyroclast-java.git

Download pyroclast-java

How to add to project

<!-- https://jarcasting.com/artifacts/io.pyroclast/pyroclast-java/ -->
<dependency>
    <groupId>io.pyroclast</groupId>
    <artifactId>pyroclast-java</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/io.pyroclast/pyroclast-java/
implementation 'io.pyroclast:pyroclast-java:1.0.1'
// https://jarcasting.com/artifacts/io.pyroclast/pyroclast-java/
implementation ("io.pyroclast:pyroclast-java:1.0.1")
'io.pyroclast:pyroclast-java:jar:1.0.1'
<dependency org="io.pyroclast" name="pyroclast-java" rev="1.0.1">
  <artifact name="pyroclast-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.pyroclast', module='pyroclast-java', version='1.0.1')
)
libraryDependencies += "io.pyroclast" % "pyroclast-java" % "1.0.1"
[io.pyroclast/pyroclast-java "1.0.1"]

Dependencies

compile (5)

Group / Artifact Type Version
org.apache.httpcomponents : httpclient jar 4.5.3
org.apache.commons : commons-io jar 1.3.2
com.fasterxml.jackson.core : jackson-core jar 2.8.6
org.codehaus.jackson : jackson-mapper-asl jar 1.9.13
org.apache.httpcomponents : httpasyncclient jar 4.1.3

Project Modules

There are no modules declared in this project.

pyroclast-java

Java API client for Pyroclast.

Installation

Maven

<dependency>
    <groupId>io.pyroclast</groupId>
    <artifactId>pyroclast-java</artifactId>
    <version>1.0.1</version>
</dependency>

Gradle

compile "io.pyroclast:pyroclast-java:1.0.1"

Topic APIs

Writing Events

Instantiate a client and producer.

import io.pyroclast.pyroclastjava.v1.topic.PyroclastTopicClient;
import io.pyroclast.pyroclastjava.v1.topic.PyroclastProducer;
import java.util.List;
import java.util.Map;

PyroclastTopicClient client = new PyroclastTopicClient()
        .withWriteApiKey("xxxxxxxxxx")
        .withTopicId("yyyyyyyyyy")
        .buildClient();

PyroclastProducer producer = client.createProducer();

Send one event synchronously

Map<Object, Object> event = new HashMap<>();
event.put("name", "mike");

producer.send(event);

Send a batch of events synchronously

Map<Object, Object> e1 = new HashMap<>();
e1.put("name", "mike");

Map<Object, Object> e2 = new HashMap<>();
e2.put("name", "ron");

List<Map<Object, Object>> events = new ArrayList<>();
events.add(e1);
events.add(e2);

producer.send(events);

Send one event asynchronously

import io.pyroclast.pyroclastjava.v1.topic.async.AsyncCancelledCallback;
import io.pyroclast.pyroclastjava.v1.topic.async.AsyncFailCallback;
import io.pyroclast.pyroclastjava.v1.topic.async.AsyncSuccessCallback;
import io.pyroclast.pyroclastjava.v1.topic.responses.ProducedEventResult;

Map<Object, Object> event = new HashMap<>();
event.put("car", "red");

AsyncSuccessCallback<ProducedEventResult> onSuccess = per -> System.out.println("Ok");
AsyncFailCallback onFail = e -> System.err.println(e);
AsyncCancelledCallback onCancel = status -> System.out.println("Request cancelled");

producer.send(event, onSuccess, onFail, onCancel);

Send a batch of events asynchronously

import io.pyroclast.pyroclastjava.v1.topic.responses.ProducedEventsResult;

Map<Object, Object> e1 = new HashMap<>();
e1.put("name", "mike");

Map<Object, Object> e2 = new HashMap<>();
e2.put("name", "ron");

List<Map<Object, Object>> events = new ArrayList<>();
events.add(e1);
events.add(e2);

AsyncSuccessCallback<ProducedEventsResult> onSuccess = per -> System.out.println("Ok");
AsyncFailCallback onFail = e -> System.err.println(e);
AsyncCancelledCallback onCancel = status -> System.out.println("Request cancelled");

producer.send(events, onSuccess, onFail, onCancel);

Reading events

Instantiate a client.

import io.pyroclast.pyroclastjava.v1.topic.PyroclastTopicClient;
import io.pyroclast.pyroclastjava.v1.topic.PyroclastConsumer;

PyroclastTopicClient client = new PyroclastTopicClient()
        .withReadApiKey("xxxxxxxxxx")
        .withTopicId("yyyyyyyyyy")
        .buildClient();

Subscribe to a topic

String subscriptionName = "example-subscription-name";
PyroclastConsumer consumer = client.createConsumer(subscriptionName);

Poll subscribed topic

import io.pyroclast.pyroclastjava.v1.topic.TopicRecord;
import java.util.Iterator;
import java.util.List;

List<TopicRecord> records = consumer.pollTopic().getRecords();
Iterator<TopicRecord> it = records.iterator();

while (it.hasNext()) {
    TopicRecord rec = it.next();
    System.out.println(rec.getValue());
}

Commit read records

consumer.commit();

Deployed Service APIs

Read deployed service aggregations

Instantiate a client.

import io.pyroclast.pyroclastjava.v1.deployment.PyroclastDeploymentClient;

PyroclastDeploymentClient client = new PyroclastDeploymentClient()
        .withDeploymentId("xxxxxxxxxx")
        .withReadApiKey("yyyyyyyyyy")
        .buildClient();

Get all aggregates for a deployment

import io.pyroclast.pyroclastjava.v1.deployment.DeploymentAggregates;

DeploymentAggregates aggregates = client.readAggregates().getAggregates();

Get an aggregate by name for a deployment

import io.pyroclast.pyroclastjava.v1.deployment.DeploymentAggregate;

DeploymentAggregate aggregate = client.readAggregate("aggregate-name").getAggregate();

Get a single aggregate group by name

import io.pyroclast.pyroclastjava.v1.deployment.DeploymentAggregate;

DeploymentAggregate aggregate = client.readAggregateGroup("aggregate-name", "group-name").getAggregate();

License

(The MIT License)

Copyright © 2017 Distributed Masonry

io.pyroclast

Pyroclast

The flexible, realtime event processing platform.

Versions

Version
1.0.1