# Subscriptions

> React to events as they are written, in a blocking or a reactive model.

[Layer 0: CloudEvents](/docs/layer-0/)

A subscription is a way to get notified when new events are written to an event store. Typically, a subscription will be used to create views from events (such as projections, sagas, snapshots etc) or create integration events that can be forwarded to another piece of infrastructure such as a message bus. There are two different kinds of APIs, the first one is a [blocking API](/docs/layer-0/blocking-subscriptions/) represented by the `org.occurrent.subscription.api.blocking.SubscriptionModel` interface (in the `org.occurrent:occurrent-subscription-api-blocking` module), and second one is a [reactive API](/docs/layer-0/reactive-subscriptions/) represented by the `org.occurrent.subscription.api.reactor.FluxSubscriptionModel` interface (in the `org.occurrent:occurrent-subscription-api-reactor` module).

The blocking API is callback based, which is fine if you’re working with individual events (you can of course use a simple function that aggregates events into batches yourself). If you want to work with streams of data, the reactor `FluxSubscriptionModel` is probably a better option since it’s using the [Flux](https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html) publisher from [project reactor](https://projectreactor.io/).

Note that it’s fine to use reactive `FluxSubscriptionModel`, even though the event store is implemented using the blocking api, and vice versa. If the datastore allows it, you can also run subscriptions in a different process than the processes reading and writing to the event store.

To get started with subscriptions refer to [Using Subscriptions](/docs/layer-0/subscriptions/#using-subscriptions).

Independently of the blocking-versus-reactive choice above, a subscription is either asynchronous or synchronous. Everything so far is asynchronous: it runs on its own thread and fires after the write commits. A [synchronous subscription](/docs/layer-1/synchronous-subscriptions/) instead runs inline on the writer thread, before `execute` returns, so it can update a projection in the write path and, with a transaction, atomically with the write.

[]()

> **Note**
>
> Before you start using subscriptions you should read up on what they are [here](/docs/layer-0/subscriptions/).

There are two different kinds of subscriptions, [blocking subscriptions](/docs/layer-0/blocking-subscriptions/) and [reactive subscriptions](/docs/layer-0/reactive-subscriptions/). For blocking subscription implementations see [here](/docs/layer-0/blocking-subscription-models/) and for reactive subscription implementations see [here](/docs/layer-0/reactive-subscription-models/).