# Events Store (/sdks/java/reference/events-store)



`PubSubClient` exposes both `publishEventStore` and `subscribeToEventsStore` for persisted events with configurable replay positions.

## publishEventStore [#publisheventstore]

```java
EventSendResult publishEventStore(EventStoreMessage message) throws KubeMQException
```

Persists an event and returns acknowledgement metadata.

> `sendEventsStoreMessage` is a deprecated alias (`forRemoval=true`) for `publishEventStore` — prefer `publishEventStore` in new code.

**Parameters:**

| Name      | Type                | Required | Description            |
| --------- | ------------------- | -------- | ---------------------- |
| `message` | `EventStoreMessage` | Yes      | Channel, payload, tags |

**Returns:** `EventSendResult` — IDs and timestamps from the broker.

## subscribeToEventsStore [#subscribetoeventsstore]

```java
void subscribeToEventsStore(EventsStoreSubscription subscription) throws KubeMQException
```

Subscribes with replay parameters supplied on `EventsStoreSubscription`.

**Parameters:**

| Name           | Type                      | Required | Description                             |
| -------------- | ------------------------- | -------- | --------------------------------------- |
| `subscription` | `EventsStoreSubscription` | Yes      | Channel, group, replay start, callbacks |

## Replay options [#replay-options]

| Field               | Description                                                                                             |
| ------------------- | ------------------------------------------------------------------------------------------------------- |
| Start position enum | `StartNewOnly`, `StartFromFirst`, `StartFromLast`, `StartAtSequence`, `StartAtTime`, `StartAtTimeDelta` |
| Companion value     | Sequence number or epoch millis when required by the enum                                               |

## Quick Usage [#quick-usage]

```java title="EventsStore.java"
try (PubSubClient pub = PubSubClient.builder()
        .address("localhost:50000")
        .clientId("store-demo")
        .build()) {
    EventStoreMessage msg = EventStoreMessage.builder()
        .channel("audit.security")
        .body(payload)
        .build();
    pub.publishEventStore(msg);
}
```

## See Also [#see-also]

* [Events Store Examples](/sdks/java/how-to/events-store/)
* [Events Store pattern](/learn/events-store/getting-started)
* [Java SDK Getting Started](/sdks/java)
