Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/pages/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ To manage your subscriptions there are the following cli commands.
!!! note

You can find out more about subscriptions [here](subscription.md).

## Inspector commands

The inspector is a tool to inspect the event streams.
Expand Down
6 changes: 6 additions & 0 deletions docs/pages/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@ $hotelRepository = $repositoryManager->get(Hotel::class);
`DefaultRepositoryManager` and a worker to run the Subscription Engine.

Learn more [here](subscription.md).

!!! warning
From version 4.x onward, a MessageLoader will be required for the SubscriptionEngine
instead of a Store implementation.
Read more about it [here](./subscription.md#message-loader). In current versions,
you can still provide a Store, the SubscriptionEngine will wrap it internally.

## Database setup

Expand Down
44 changes: 40 additions & 4 deletions docs/pages/subscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -838,13 +838,28 @@ In order for the subscription engine to be able to do its work, you have to asse
### Message Loader

The subscription engine needs a message loader to load the messages.
We provide two implementations by default.
We provide three implementations by default.
Which one has a better performance depends on the use case.

!!! tip

We recommend the `GapResolverStoreMessageLoader` as it handles gaps in the stream.
We recommend the recent `GapResolverStoreMessageLoader` as it handles gaps in the stream.

!!! note

If you followed the confiration in the [Getting Started](./getting_started.md#configuration) section,
the Message Loader implementation replaces the $eventStore in the DefaultSubscriptionEngine.

```php
$messageLoader = // whatever implementation you choose
$engine = new DefaultSubscriptionEngine(
- $eventStore,
+ $messageLoader,
$subscriptionStore,
$subscriberRepository,
);
```
Comment thread
Brammm marked this conversation as resolved.

#### Store Message Loader

The store message loader loads all the messages from the event store.
Expand Down Expand Up @@ -1169,6 +1184,12 @@ $catchupSubscriptionEngine = new CatchUpSubscriptionEngine($subscriptionEngine);
!!! tip

You can use the `CatchUpSubscriptionEngine` in your tests to process the events immediately.

!!! Note

Learn more about the worker [here](./cli.md#subscription-commands).

## Subscription Lifecycle

### Throw on error Subscription Engine

Expand Down Expand Up @@ -1222,7 +1243,10 @@ $eventBus = new RunSubscriptionEngineRepositoryManager(
!!! tip

You can perfectly use it in development or testing.
Especially in combination with the `CatchUpSubscriptionEngine` and `ThrowOnErrorSubscriptionEngine` decorators.
Especially in combination with the `CatchUpSubscriptionEngine` and `ThrowOnErrorSubscriptionEngine`
decorators.
Do note that, if you use this, you still need to make sure subscriptions are set up and booted.
Otherwise, subscriptions will only be processed on subsequent requests.

## Usage

Expand All @@ -1240,7 +1264,9 @@ $criteria = new SubscriptionEngineCriteria(
!!! note

An `OR` check is made for the respective criteria and all criteria are checked with an `AND`.


All of the following steps have equivalent commands in the [CLI](./cli.md).

### Setup

New subscriptions need to be set up before they can be used.
Expand Down Expand Up @@ -1359,6 +1385,16 @@ use Patchlevel\EventSourcing\Subscription\Engine\SubscriptionEngineCriteria;
/** @var SubscriptionEngine $subscriptionEngine */
$subscriptionEngine->refresh(new SubscriptionEngineCriteria());
```

## Basic workflow for the worker

Use `event-sourcing:subscription:boot --setup` to first run the setup of any new subscriptions
and immediately boot them.

The `event-sourcing:subscription:run` command will continue to run and process new events
until the process is killed. After adding a new subscriber and booting it, you should
restart the `run` command.

## Learn more

* [How to use CLI commands](./cli.md)
Expand Down
Loading