Package io.zenoh.query
Class Queryable
-
- All Implemented Interfaces:
-
io.zenoh.session.SessionDeclaration
,java.lang.AutoCloseable
public class Queryable implements AutoCloseable, SessionDeclaration
A queryable that allows to perform multiple queries on the specified KeyExpr.
Its main purpose is to keep the queryable active as long as it exists.
Example using the default BlockingQueueHandler handler:
try (Session session = Zenoh.open(config)) { var queryable = session.declareQueryable(keyExpr); BlockingQueue<Optional<Query>> receiver = queryable.getReceiver(); assert receiver != null; while (true) { Optional<Query> wrapper = receiver.take(); if (wrapper.isEmpty()) { break; } Query query = wrapper.get(); query.reply(query.getKeyExpr(), "Example reply"); } }
Example using a io.zenoh.handlers.Callback:
try (Session session = Zenoh.open(config)) { var queryable = session.declareQueryable(keyExpr, query -> query.reply(query.getKeyExpr(), "Example reply"); }
-
-
Method Summary
-
-
Method Detail
-
getKeyExpr
final KeyExpr getKeyExpr()
The KeyExpr to which the subscriber is associated.
-
-
-
-