Interface RxResult

All Known Implementing Classes:
InternalRxResult

@Deprecated public interface RxResult
Deprecated.
superseded by ReactiveResult and ReactiveResult
A reactive result provides a reactive way to execute query on the server and receives records back. This reactive result consists of a result key publisher, a record publisher and a result summary publisher. The reactive result is created via RxQueryRunner.run(Query) and RxQueryRunner.run(Query) for example. On the creation of the result, the query submitted to create this result will not be executed until one of the publishers in this class is subscribed. The records or the summary stream has to be consumed and finished (completed or errored) to ensure the resources used by this result to be freed correctly.
Since:
4.0
See Also:
  • Publisher
  • Subscriber
  • Subscription
  • Method Summary

    Modifier and Type
    Method
    Description
    org.reactivestreams.Publisher<ResultSummary>
    Deprecated.
    Returns a cold publisher of result summary which arrives after all records.
    org.reactivestreams.Publisher<Boolean>
    Deprecated.
    Determine if result is open.
    org.reactivestreams.Publisher<List<String>>
    Deprecated.
    Returns a cold publisher of keys.
    org.reactivestreams.Publisher<Record>
    Deprecated.
    Returns a cold unicast publisher of records.
  • Method Details

    • keys

      org.reactivestreams.Publisher<List<String>> keys()
      Deprecated.
      Returns a cold publisher of keys. This publisher always publishes one item - a list of keys. The list could be empty which indicates no keys in the result.

      When this publisher is subscribed, the query is sent to the server and executed. This method does not start the record streaming nor publish query execution result. To retrieve the execution result, either records() or consume() can be used. records() starts record streaming and reports query execution result. consume() skips record streaming and directly reports query execution result.

      Consuming of execution result ensures the resources (such as network connections) used by this result is freed correctly. Consuming the keys without consuming the execution result will result in resource leak. To avoid the resource leak, RxSession.close() (and/or RxTransaction.commit() and RxTransaction.rollback()) shall be invoked and subscribed to enforce the result resources created in the RxSession (and/or RxTransaction) to be freed correctly.

      This publisher can be subscribed many times. The keys published stays the same as the keys are buffered. If this publisher is subscribed after the publisher of records() or consume(), then the buffered keys will be returned.

      Returns:
      a cold publisher of keys.
    • records

      org.reactivestreams.Publisher<Record> records()
      Deprecated.
      Returns a cold unicast publisher of records.

      When the record publisher is subscribed, the query is executed and the result is streamed back as a record stream followed by a result summary. This record publisher publishes all records in the result and signals the completion. However before completion or error reporting if any, a cleanup of result resources such as network connection will be carried out automatically.

      Therefore the Subscriber of this record publisher shall wait for the termination signal (complete or error) to ensure that the resources used by this result are released correctly. Then the session is ready to be used to run more queries.

      Cancelling of the record streaming will immediately terminate the propagation of new records. But it will not cancel query execution on the server. When the execution is finished, the Subscriber will be notified with a termination signal (complete or error).

      The record publishing event by default runs in an Network IO thread, as a result no blocking operation is allowed in this thread. Otherwise network IO might be blocked by application logic.

      This publisher can only be subscribed by one Subscriber once.

      If this publisher is subscribed after keys(), then the publish of records is carried out after the arrival of keys. If this publisher is subscribed after consume(), then a ResultConsumedException will be thrown.

      Returns:
      a cold unicast publisher of records.
    • consume

      org.reactivestreams.Publisher<ResultSummary> consume()
      Deprecated.
      Returns a cold publisher of result summary which arrives after all records.

      Subscribing the summary publisher results in the execution of the query followed by the result summary being returned. The summary publisher cancels record publishing if not yet subscribed and directly streams back the summary on query execution completion. As a result, the invocation of records() after this method, would receive an ResultConsumedException.

      If subscribed after keys(), then the result summary will be published after the query execution without streaming any record to client. If subscribed after records(), then the result summary will be published after the query execution and the streaming of records.

      Usually, this method shall be chained after records() to ensure that all records are processed before summary.

      This method can be subscribed multiple times. When the summary arrives, it will be buffered locally for all subsequent calls.

      Returns:
      a cold publisher of result summary which only arrives after all records.
    • isOpen

      org.reactivestreams.Publisher<Boolean> isOpen()
      Deprecated.
      Determine if result is open.

      Result is considered to be open if it has not been consumed (consume()) and its creator object (e.g. session or transaction) has not been closed (including committed or rolled back).

      Attempts to access data on closed result will produce ResultConsumedException.

      Returns:
      a publisher emitting true if result is open and false otherwise.