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");
    }
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final KeyExpr keyExpr
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final KeyExpr getKeyExpr() The KeyExpr to which the subscriber is associated.
      final Boolean isValid()
      Unit undeclare() Undeclares the queryable.
      Unit close() Closes the queryable, equivalent to undeclare.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait