Java

Similar to the Python client, this client also wraps the rust but does not yet support any admin features. The calls to using fluvio objects across the network are all blocking.

To see the full docs, visit our javadoc page.

 

Connect

To get a connection to fluvio do:

Fluvio fluvio = Fluvio.connect();
 

Producer

To create a producer do:

TopicProducer producer = fluvio.topic_producer("hello-java");
 

Send

To send to the topic do:

for (int i = 0; i < 10; i++) {
    producer.send(String.valueOf(i).getBytes(), ("Hello " + i).getBytes());
}
 

Consumer

To create a consumer do:

PartitionConsumer consumer = fluvio.partition_consumer("hello-java", 0);
 

Stream

For now usage of the consumer stream requires calling next on the stream as seen here:

PartitionConsumerStream stream = consumer.stream(Offset.beginning());
for (int i = 0; i < 10; i++) {
    Record record = stream.next();
    System.out.printf("Consumed record, key=%s, value=%s\n", record.key_string(), record.value_string());
}