DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Analysis of Failure Modes in Producer-Consumer Systems
  • Mastering Backpressure in Java: Concepts, Real-World Examples, and Implementation
  • Understanding Kafka and Event-Driven Architecture [Video Tutorials]
  • Spring Boot and Apache Kafka [Video Tutorials]

Trending

  • Next Evolution in Integration: Architecting With Intent Using Model Context Protocol
  • Blue Skies Ahead: An AI Case Study on LLM Use for a Graph Theory Related Application
  • Secure by Design: Modernizing Authentication With Centralized Access and Adaptive Signals
  • Agile’s Quarter-Century Crisis

An Introduction to Event-Based Programming

By 
Madhuka  Udantha user avatar
Madhuka Udantha
·
Jun. 12, 14 · Interview
Likes (1)
Comment
Save
Tweet
Share
16.4K Views

Join the DZone community and get the full member experience.

Join For Free

This post looks at how applications components typically interact. Event-based programming, also called event-driven architecture (EDA) is an architectural style in which one or more components in a software system execute in response to receiving one or more event notifications.

1. Request-response interactions

Client formulate a request, It is sent across the internet to a web server. Client wait while the server constructs a response. This response is returned across the internet to client.

image

In a synchronous interaction the provider is expected to send a response back

image

2. Events and the principle of decoupling

Events are sometimes used to represent changes of state. The system being monitored is represented as a set of resources each of which is associated with state information. Event producers send events then internal state values change. This allows monitoring applications to be notified immediately when something happens, without their having to continually poll all the resources.

In a decoupled event processing system an event producer does not depend on a particular processing or course of action being taken by an event consumer. Moreover, an event consumer does not depend on processing performed by the producer other than the production of the event itself.

Above chart shows Decoupling of Entities from Object-Orientation to Event-Driven Architecture.

3. Push-style event interactions
 
In here events are often sent as one-way messages. It pushes the event to each consumer as a one-way message as below diagram. Event producer wait for a response from the consumer

image

4.  Channel-based event distribution

In 3 model, producer has to send multiple copies of the same event to consumers. The event producer can find their identities by consulting an external information source.

image

5. Request-response interactions to distribute events

In pull-style distribution, the consumer uses the standard request-response pattern to request an event from a producer, or from an intermediary channel.To avoid having to hold on to events and to avoid having to service requests from multiple consumers, event consumer 1 sending a pull request directly to the event producer (message 1).
producer uses a regular push (message 3) to send the event to the channel, and consumer 2 requests it (message 3.1) from the channel. This approach can be extended to send multiple events in
the response messages.

image

Where is this useful

  • A consumer that is only available occasionally
  • A producer that is unable to distribute events
  • A consumer that is physically unable to receive unsolicited incoming events(eg: due to firewall)
  • A consumer that wants to regulate its processing of events and have control
    over exactly when it receives them

 

Event consumer producer

Published at DZone with permission of Madhuka Udantha, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Analysis of Failure Modes in Producer-Consumer Systems
  • Mastering Backpressure in Java: Concepts, Real-World Examples, and Implementation
  • Understanding Kafka and Event-Driven Architecture [Video Tutorials]
  • Spring Boot and Apache Kafka [Video Tutorials]

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!