Event (computing)

Computing operation

It has been suggested that Event (synchronization primitive) be merged into this article. (Discuss) Proposed since December 2024.

|

In computing, an event is a detectable occurrence or change in the system's state, such as user input, hardware interrupts, system notifications, or changes in data or conditions, that the system is designed to monitor. Events trigger responses or actions and are fundamental to event-driven systems. These events can be handled synchronously, where the execution thread is blocked until the event handler completes its processing, or asynchronously, where the event is processed independently, often through an event loop. Even when synchronous handling appears to block execution, the underlying mechanism in many systems is still asynchronous, managed by the event loop. [1][2]

Events can be implemented through various mechanisms such as callbacks, message objects, signals, or interrupts, and events themselves are distinct from the implementation mechanisms used. Event propagation models, such as bubbling, capturing, and pub/sub, define how events are distributed and handled within a system. Other key aspects include event loops, event queueing and prioritization, event sourcing, and complex event processing patterns. These mechanisms contribute to the flexibility and scalability of event-driven systems. [1][2]

## Events vs. Messages

[edit]

In distributed systems, events represent a fact or state change (e.g., OrderPlaced) and are typically broadcast asynchronously to multiple consumers, promoting loose coupling and scalability. While events generally don’t expect an immediate response, acknowledgment mechanisms are often implemented at the infrastructure level (e.g., Kafka commit offsets, SNS delivery statuses) rather than being an inherent part of the event pattern itself. [3][4]

In contrast, messages serve a broader role, encompassing commands (e.g., ProcessPayment), events (e.g., PaymentProcessed), and documents (e.g., DataPayload). Both events and messages can support various delivery guarantees, including at-least-once, at-most-once, and exactly-once, depending on the technology stack and implementation. However, exactly-once delivery is often achieved through idempotency mechanisms rather than true, infrastructure-level exactly-once semantics. [3][4]

Delivery patterns for both events and messages include publish/subscribe (one-to-many) and point-to-point (one-to-one). While request/reply is technically possible, it is more commonly associated with messaging patterns rather than pure event-driven systems. Events excel at state propagation and decoupled notifications, while messages are better suited for command execution, workflow orchestration, and explicit coordination. [3][4]

Modern architectures commonly combine both approaches, leveraging events for distributed state change notifications and messages for targeted command execution and structured workflows based on specific timing, ordering, and delivery requirements. [3][4]

## Event Evolution Strategies

[edit]

In distributed systems, event evolution poses challenges, such as managing inconsistent event schemas across services and ensuring compatibility during gradual system updates. Event evolution strategies in event-driven architectures (EDA) can ensure that systems can handle changes to events without disruption. These strategies can include versioning events, such as semantic versioning or schema evolution, to maintain backward and forward compatibility. Adapters can translate events between old and new formats, ensuring consistent processing across components. These techniques can enable systems to evolve while remaining compatible and reliable in complex, distributed environments. [1]

## See also

[edit]

* Callback (computer programming)
* Database trigger
* DOM events
* Event-driven programming
* Exception handling
* Interrupt handler
* Interrupts
* Observer pattern (e.g., Event listener)
* Reactor pattern vs. Proactor pattern
* Signal programming
* Virtual synchrony

## References

[edit]

1. ^ a b c Designing Event-Driven Systems. O'Reilly Media. ISBN 9781492038245.
2. ^ a b Fowler, Martin (2003). Patterns of Enterprise Application Architecture. Addison-Wesley Professional. ISBN 978-0321127426.
3. ^ a b c d Kleppmann, Martin (2017). Designing Data-Intensive Applications: The Big Ideas Behind Reliable, Scalable, and Maintainable Systems. O'Reilly Media. ISBN 978-1449373320.
4. ^ a b c d Building Event-Driven Microservices: Leveraging Organizational Data at Scale. ISBN 978-1492057895.

## External links

[edit]

* Article Event Handlers and Callback Functions
* A High Level Design of the Sub-Farm Event Handler
* An Events Syntax for XML
* Distributed Events and Notifications
* Event order
* `Java DOM Interface Event` Javadoc documentation
* `java.awt.event` Java package Javadoc API documentation
* `javax.swing.event` Java package Javadoc API documentation
* Write an Event Handler
* Understand Events (Logs and Metrics)