You are currently browsing legacy 4.0 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Changes API: How to Subscribe to Operation Changes

The following methods allow you to subscribe to operation changes:

forOperation

Operation changes for one operation can be observed using the forOperationId method.

Syntax

IChangesObservable<OperationStatusChange> forOperationId(long operationId);

Parameters
operationId long ID of an operation for which notifications will be processed.
Return value
IChangesObservable<OperationStatusChange> Observable that allows you to add subscriptions to notifications for an operation with a given ID.

Example

CleanCloseable subscription = store
    .changes()
    .forOperationId(operationId)
    .subscribe(Observers.create(change -> {
        ObjectNode operationState = change.getState();

        // do something
    }));

forAllOperations

Operations changes for all Operations can be observed using the forAllOperations method.

Return Value
IChangesObservable<OperationStatusChange> Observable that allows to add subscriptions to notifications for all operations.

Syntax

IChangesObservable<OperationStatusChange> forAllOperations();

Example

CleanCloseable subscription = store
    .changes()
    .forAllOperations()
    .subscribe(Observers.create(change -> {
        System.out.println("Operation #" + change.getOperationId());
    }));

OperationChange

Properties

Name Type Description
State ObjectNode Operation state
OperationId long Operation ID