---
title: "Changes API: How to Subscribe to Operation Changes"
url: "https://docs.ravendb.net/6.2/client-api/changes/how-to-subscribe-to-operation-changes"
version: "6.2"
language: "java"
---

# Changes API: How to Subscribe to Operation Changes

> Client language: Java. Also available for [C#](https://docs.ravendb.net/6.2/client-api/changes/how-to-subscribe-to-operation-changes.md), [Node.js](https://docs.ravendb.net/6.2/client-api/changes/how-to-subscribe-to-operation-changes.nodejs.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

The following methods allow you to subscribe to operation changes:

- [forOperationId](#foroperation)
- [forAllOperations](#foralloperations)

## forOperation

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

### Syntax

```java
IChangesObservable<OperationStatusChange> forOperationId(long operationId);
```

| Parameters | | |
| - | - | - |
| **operationId** | long | ID of an operation for which notifications will be processed. |

| Return value | |
| - | - |
| IChangesObservable<[OperationStatusChange](#operationchange)> | Observable that allows you to add subscriptions to notifications for an operation with a given ID. |

### Example

```java
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](#operationchange)> | Observable that allows to add subscriptions to notifications for all operations. |

### Syntax

```java
IChangesObservable<OperationStatusChange> forAllOperations();
```

### Example

```java
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 |

## See also

- [What is Changes API](https://docs.ravendb.net/6.2/client-api/changes/what-is-changes-api.java.md)
- [How to Subscribe to Index Changes](https://docs.ravendb.net/6.2/client-api/changes/how-to-subscribe-to-index-changes.java.md)
