Publisher

A Zenoh Publisher.

A publisher is automatically dropped when using it with the 'try-with-resources' statement (i.e. 'use' in Kotlin). The session from which it was declared will also keep a reference to it and undeclare it once the session is closed.

In order to declare a publisher, Session.declarePublisher must be called, which returns a Publisher.Builder from which we can specify the Priority, and the CongestionControl.

Example:

try (Session session = Session.open()) {
try (KeyExpr keyExpr = KeyExpr.tryFrom("demo/java/greeting")) {
System.out.println("Declaring publisher on '" + keyExpr + "'...");
try (Publisher publisher = session.declarePublisher(keyExpr).res()) {
int i = 0;
while (true) {
publisher.put("Hello for the " + i + "th time!").res();
Thread.sleep(1000);
i++;
}
}
}
} catch (ZenohException | InterruptedException e) {
System.out.println("Error: " + e);
}

The publisher configuration parameters can be later changed using the setter functions.

Types

Link copied to clipboard
class Builder

Publisher Builder.

Link copied to clipboard
object Companion
Link copied to clipboard
Link copied to clipboard
class Put : Resolvable<Unit>

Properties

Link copied to clipboard

The key expression the publisher will be associated to.

Functions

Link copied to clipboard
open override fun close()
Link copied to clipboard

Performs a DELETE operation on the specified keyExpr

Link copied to clipboard

Get congestion control policy.

Link copied to clipboard

Get priority policy.

Link copied to clipboard
open override fun isValid(): Boolean

Returns true if the declaration has not been undeclared.

Link copied to clipboard
fun put(value: Value): Publisher.Put

Performs a PUT operation on the specified keyExpr with the specified value.

fun put(value: String): Publisher.Put

Performs a PUT operation on the specified keyExpr with the specified string value.

Link copied to clipboard
open override fun undeclare()

Undeclare a declaration. No further operations should be performed after calling this function.