CompanyJuly 6, 2022

Building Scalable Streaming Applications with DataStax Astra Streaming

Jeff Davies
Jeff DaviesData Architect
Building Scalable Streaming Applications with DataStax Astra Streaming
public Flight(String flightID, String aircraftType) {
try {
// Initialize our location
Date now = new Date();
objLoc = new ObjectLocation(flightID, aircraftType, 0.0, 0.0,
now.getTime());
// Create client object
client = PulsarClient.builder()
.serviceUrl(BROKER_SERVICE_URL)
.authentication(
AuthenticationFactory.token(Credentials.token)
)
.build();
// Create producer on a topic
producer = client.newProducer(JSONSchema.of(ObjectLocation.class))
.topic("persistent://" + STREAM_NAME + "/" + NAMESPACE + "/" + TOPIC)
.create();
} catch(Exception ex) {
System.out.println(ex.getMessage());
}
}
public void run() {
// Send a message to the topic
try {
producer.send(objLoc);
System.out.println(objLoc.toString());
Date now = new Date();
updatePosition(objLoc);
objLoc.setTs(now.getTime());
} catch(PulsarClientException pcex) {
pcex.printStackTrace();
}
}
package com.datastax.pulsar;
public class Credentials {
public static String token = "YOUR TOKEN INFO HERE";
}
Discover more
DataStax Astra DB
Share

One-stop Data API for Production GenAI

Astra DB gives JavaScript developers a complete data API and out-of-the-box integrations that make it easier to build production RAG apps with high relevancy and low latency.