The main purpose of Business Events is to provide notifications of interesting events in other apps, to be used in combination with APIs.
Currently, when you have multiple apps connected through APIs, and realtime processing is crucial, you either:
* need to poll frequently for changes (introduces delays, and high overhead on the service),
* implement webhooks including retry mechanisms (complex to build),
* or have a tight coupling between service and clients where the service calls the relevant clients.
Business Events allows you to build apps that respond in near real-time to other apps in an easier and more decoupled way.
With fat events you need to consider security: who might receive this event in the future, and what data can i include in the fat event that doesn’t risk security? A thin event only provides a notification of the event, and an id of the relevant object. Any details can be retrieved securely using the id through an API (either REST or OData).
If you want to build fat events, the option is to mapping the objects into a json structure with export mappings, and place the resulting json payload in a string attribute of the business events. Due to the security considerations, and the strict ordering requirements on event processing we advice to use thin notication events.
Feel free to contact me (andrej.koelewijn at mendix.com) to discuss details.
Thanks for the answer! It’s great to understand Mendix’ ideas behind the implementation of Business Events.
My main point of concern is the asynchronous processing of the events and the possibility that introduces to retrieve the wrong state via the API. Assuming events are processed sequentially, which is true in our case, here is the challenge. If the subscribed app takes some time processing an event, it is possible that the publishing app has fired mulltiple events already, which are queued at the consumer app. The moment the subscribing app picks up the next event, the state of the data in the publishing app could have been changed multiple times already. The subscribing app is picking up the current state of the data and is doing that for every queued event. This results in one interesting change and a serie of non changes.
The result is that it is not possible for the subscribing app to receive all the separate changes.
If that’s not important for the receiving app, that’s not a problem. If there is no change, nothing needs to be done. But if the subscribing app needs to be aware of all the changes, it is a problem.
What do you think? Is this a corner case or is this a legitimate concern?
Discussing this with myself in my head: I can imagine that, if it is important to be aware of every change, you should model for that and capture every change explicitly – in a change log or something. And that, normally, changes can be stacked and processed as one change instead of multiple smaller ones.