You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, events are not published over a bus when inserted into a store. To automatically publish inserted events, a decorator can be used:
package example
funcexample(store event.Store, bus event.Bus) {
// store publishes events over the given bus after insertion into the storestore=eventstore.WithBus(store, bus)
}
This has a flaw: when the process crashes between the insert and publish, the event will never be published, causing a "data-loss" (not really, the event was inserted into the store). If such an event would trigger a projection, the projection would likely be in an invalid state until it is manually reset by a user/developer because there is no way for a projection to know that it is missing events (not even through a projection.Progressor).
Proposal
Proposal is to create a service that uses the MongoDB Change Streams feature to tail the oplog of the event store. When an event is inserted into the database, the oplog notifies the service, which then publishes the event over the event bus.
Change Streams provide a "resume token" which are used to resume tailing the oplog after a service crash/restart. This should ensure that no events are "dropped" / all inserted events are eventually published.
The text was updated successfully, but these errors were encountered:
bounoable
changed the title
MongoDB Oplog Tailing
Publish events using MongoDB Change Streams
Mar 29, 2022
By default, events are not published over a bus when inserted into a store. To automatically publish inserted events, a decorator can be used:
This has a flaw: when the process crashes between the insert and publish, the event will never be published, causing a "data-loss" (not really, the event was inserted into the store). If such an event would trigger a projection, the projection would likely be in an invalid state until it is manually reset by a user/developer because there is no way for a projection to know that it is missing events (not even through a
projection.Progressor
).Proposal
Proposal is to create a service that uses the MongoDB Change Streams feature to tail the oplog of the event store. When an event is inserted into the database, the oplog notifies the service, which then publishes the event over the event bus.
Change Streams provide a "resume token" which are used to resume tailing the oplog after a service crash/restart. This should ensure that no events are "dropped" / all inserted events are eventually published.
The text was updated successfully, but these errors were encountered: