ArticleslgStudy

computer science

Event-driven messaging

Event-driven messaging is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Event-driven messaging rather than just read about it. In short: The event-driven messaging is a design pattern to enable the service consumers, which are interested in events that occur within the periphery of a service provider, to get notifications about these events as and when they occur without resorting to the traditional inefficient polling based mechanism. It's important to differentiate between event-driven and message-driven (a.k.a. queue driven) services: Event-driven…

Event-driven messaging — main illustration
Event-driven messaging — illustration

Key takeaways

  • Event-driven messaging belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Event-driven messaging to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Event-driven messaging from memory before moving on to harder problems.

Reference excerpt

The event-driven messaging is a design pattern to enable the service consumers, which are interested in events that occur within the periphery of a service provider, to get notifications about these events as and when they occur without resorting to the traditional inefficient polling based mechanism. It's important to differentiate between event-driven and message-driven (a.k.a. queue driven) services: Event-driven services (e.g. AWS SNS) are decoupled from their consumers. Whereas queue / message driven services (e.g. AWS SQS) are coupled with their consumers.

Rationale The interaction between a service consumer and a service provider is normally initiated by the service consumer as it needs to respond to an event that occurs within the boundary of the service consumer itself, e.g. requiring some data from an external resource (i.e. the service provider) in order to perform a calculation whose results need to be relayed back to a user interface in response to an action performed by the user. However, there are situations where the service consumer needs to wait for the occurrence of an event within the boundary of the service provider itself. Under these circumstances, the service consumer somehow needs to be informed of the event as and when it happens. One way is to program the service consumer to poll the service provider with regular intervals so that it can check if the event happened or not. This approach not only manifests inefficiency but also behavioral unpredictability. Inefficiency because the service consumer and the service provider are engaged in unproductive interactions and unreliable because it might be that the event actually happened more than once before the service consumer could poll the service provider, thereby missing the previous events and their related data. Apart from these problems, such a technique also introduces latency as the interval with which the service consumer performs the polling is fixed and, therefore, it would only fetch the event data at that time and not when the event actually occurred. This whole scenario deteriorates even further if multiple service consumers are dependent on a particular service provider. In order to tackle this problem, the event-driven messaging design pattern suggests a publisher-subscriber communication mechanism that ensures timely notification of event related data to the service consumer, thereby eliminating the inefficiencies linked with the traditional polling based communication mechanism.

Usage

The application of the event-driven messaging design pattern requires an event manager with whom the service provider registers its events. The service consumers then register their interest in some or all of the advertised events. Upon the occurrence of an event, the service provider informs the event manager that then notifies all the registered service consumers instantly. This communication mechanism shares its roots with the Observer pattern applied traditionally within the object-oriented world. This design pattern also borrows some concepts from the Event-Driven Architecture as the fundamental rationale behind this design pattern is responding to events. The actual implementation of such a publisher–subscriber-based communication mechanism requires architectural extensions in order to provide such a complex message tracking and forwarding mechanism. A mature ESB product should normally be able to provide such functionality. The application of this pattern helps to further decouple the service consumers from the service providers and increases the overall reliability of a service composition.

References

Erl et al.,(2009).SOA Design Patterns. Prentice Hall. ISBN 0-13-613516-1. Michael Stal.Using Architectural Patterns and Blueprints for Service-Oriented Architecture[Online].Date accessed: 1 May 2010.

External links SOA Patterns

Illustrations

Event-driven messaging: Diagram BThe event manager automatically notifies all the interested service consumers about the occurrence of a particular event the moment it actually happens.
Diagram BThe event manager automatically notifies all the interested service consumers about the occurrence of a particular event the moment it actually happens.

Worked examples

Example 1 — a first encounter with Event-driven messaging

Start with the simplest possible case. Write down what Event-driven messaging claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Event-driven messaging before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Event-driven messaging ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Event-driven messaging

In research
Event-driven messaging appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Event-driven messaging in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Event-driven messaging is common in secondary-school and first-year university syllabi. It links to neighbouring topics Service-oriented (business computing), so understanding it makes those chapters shorter.
In everyday life
Look for Event-driven messaging outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Event-driven messaging” →

How to study Event-driven messaging in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Event-driven messaging means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Event-driven messaging out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Event-driven messaging in simple terms?

The event-driven messaging is a design pattern to enable the service consumers, which are interested in events that occur within the periphery of a service provider, to get notifications about these events as and when they occur without resorting to the traditional inefficient polling based mechani…

Why does Event-driven messaging matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Event-driven messaging?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Event-driven messaging.

Tags

  • Service-oriented (business computing)

Keep exploring