For running the examples, there are two approaches. Either you run the gradle example task with the syntax gradle <example> --args="<arguments>"
or you can build fat JARs the examples through the task gradle buildExamples
.
While both are valid, in this document we'll follow the second approach; when running gradle buildExamples
, all the JARs will be located under /examples/build/libs
, which can later be executed
java -jar <Example>.jar <arguments>
for instance
java -jar ZPub.jar -h
will return
Usage: zpub [<options>]
Zenoh Pub example
Options:
-k, --key=<key> The key expression to write to [default: demo/example/zenoh-kotlin-pub]
-c, --config=<config> A configuration file.
-e, --connect=<connect> Endpoints to connect to.
-l, --listen=<listen> Endpoints to listen on.
-m, --mode=<mode> The session mode. Default: peer. Possible values: [peer, client, router]
-v, --value=<value> The value to write. [Default: "Pub from Kotlin!"]
-a, --attach=<attach> The attachments to add to each put. The key-value pairs are &-separated, and = serves as the separator between key and value.
--no-multicast-scouting Disable the multicast-based scouting mechanism.
-h, --help Show this message and exit
The connect and listen parameters (that are common to all the examples) accept multiple repeated inputs. For instance:
java -jar ZPub.jar -l tcp/localhost:7447 -l tcp/localhost:7448 -l tcp/localhost:7449
There is the possibility to provide a Zenoh config file as follows
java -jar ZPub.jar -c path/to/config.json5
In that case, any other provided configuration parameters through the command line interface will not be taken into consideration.
One last comment regarding Zenoh logging for the examples, logs from the native library can be enabled through the environment variable RUST_LOG
as follows:
RUST_LOG=<level> java -jar ZPub.jar
where <level>
is the log filter (for instance debug
, warn
, error
... (see the Rust documentation)).
Declares a resource with a path and a publisher on this resource. Then puts a value using the numerical resource id. The path/value will be received by all matching subscribers, for instance the ZSub example.
Usage:
java -jar ZPub.jar
or
java -jar ZPub.jar -k demo/example/test -v "hello world"
Creates a subscriber with a key expression. The subscriber will be notified of each put made on any key expression matching the subscriber's key expression, and will print this notification.
Usage:
java -jar ZSub.jar
or
java -jar ZSub.jar -k demo/example/test
Sends a query message for a selector. The queryables with a matching path or selector (for instance ZQueryable) will receive this query and reply with paths/values that will be received by the query callback.
java -jar ZGet.jar
or
java -jar ZGet.jar -s demo/example/get
Puts a path/value into Zenoh. The path/value will be received by all matching subscribers, for instance the ZSub.
Usage:
java -jar ZPut.jar
or
java -jar ZPut.jar -k demo/example/put -v 'Put from Kotlin!'
Performs a Delete operation into a path/value into Zenoh.
Usage:
java -jar ZDelete.jar
or
java -jar ZDelete.jar -k demo/example/delete
Creates a queryable function with a key expression. This queryable function will be triggered by each call to a get operation on zenoh with a selector that matches the key expression, and will return a value to the querier.
Usage:
java -jar ZQueryable.jar
or
java -jar ZQueryable.jar -k demo/example/query
Pub/Sub throughput test. This example allows to perform throughput measurements between a publisher performing put operations and a subscriber receiving notifications of those puts.
Subscriber usage:
java -jar ZSubThr.jar
Publisher usage:
java -jar ZPubThr.jar <payload_size>
Latency tests
java -jar ZPing.jar
java -jar ZPong.jar
A scouting example. Will show information from other nodes in the Zenoh network.
java -jar ZScout.jar
The ZLiveliness example, it just announces itself to the Zenoh network by default to the key expression group1/zenoh-kotlin
.
Usage:
java -jar ZLiveliness
It can be used along with the following liveliness examples:
Gets the liveliness tokens, by default to group1/zenoh-kotlin
.
Usage:
java -jar ZGetLiveliness
Subscribes to liveliness events:
java -jar ZSubLiveliness