Commands & Events

Understanding the concept of commands and events

Domain events (or events, for short) are a very important part of any application developed on Flexbase.

Synchronous applications are fundamentally different from asynchronous applications and are written using a messaging paradigm. The messaging paradigm used in Flexbase is event driven design

Commands are messages that are sent to Flexbase to execute a domain event. The domain event can be a database update or a web service call.

Commands and events are both messages.

Commands are worded as imperatives eg. InitiateFundsTransfer. Events are worded in the past tense eg. FundsTransferCompleted

This is the foundation concept for building features in Flexbase using Pub-Sub pattern.

To state it simply, a publisher publishes events and subscriber subscribes events.

A publisher is not aware of the existence of subscribers.

For example, in the above example, the event FundsTransferCompleted can be subscribed by two subscriber SendSMStoCustomer and SendEmailtoCustomer

The event FundsTransferCompleted will have the necessary data that is needed by the Subscribers. The subscribers can call a SMS and Email service respectively.

Because the subscribers are asynchronous, decoupling of the services is achieved.

Last updated