Vladislav Ihost
Vladislav Ihost

Reputation: 2187

EventSourcing gateways (synchronize with external systems)

Are there best practices for implementation of eventsourcing gateways? The gateway is meant as infrastructure or service which allows to generate a set of events, proceeding from the status returned by some external service.

Even if application based on eventsourcing, some external uncontrollable entitles can still be present. For example, you want to synchronize users list from Azure AD, and perform prompt to service, which return users list. Then you get users list from projection, make difference with external state, and produce events to fill this difference.

Or your application is online-shop, and you should import actual USD/EUR/bitcoin ranks for showing prices. Gateway can poll some currencies provider and produce event. In simple case it's very easy, but if projection state is more complex structure, trivial import is not obvious.

Maybe is there common approach for this case?

Upvotes: 2

Views: 438

Answers (1)

Alexey Zimarev
Alexey Zimarev

Reputation: 19610

Building integration adapters that use poll-emit is normal and I personally prefer this way of doing integrations in general.

However, this has little to do with event sourcing, since what you actually need to solve your integration problems is to simulate the desired functionality that the external system will emit events on its own and you can build a reactive system that consumes these events.

When these events come to your system from the adapter - you can do whatever you want with them but essentially, event sourcing assumes that you store your own object's state in event streams but in case the event comes from some external system - it is not your state. You can derive your system state from external events but these will be your own events.

Upvotes: 4

Related Questions