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

  • Tired of Spring Overhead? Try Dropwizard for Your Next Java Microservice
  • Build a Stateless Microservice With GitHub Copilot in VSCode
  • From Prompt to Running Microservice: ServiceBricks Step-By-Step
  • Dropwizard vs. Micronaut: Unpacking the Best Framework for Microservices

Trending

  • Navigating the LLM Landscape: A Comparative Analysis of Leading Large Language Models
  • Agentic AI and Generative AI: Revolutionizing Decision Making and Automation
  • Building AI-Driven Intelligent Applications: A Hands-On Development Guide for Integrating GenAI Into Your Applications
  • How to Format Articles for DZone
  1. DZone
  2. Data Engineering
  3. Data
  4. Asynchronous Communication With Queues and Microservices: A Perfect Combination?

Asynchronous Communication With Queues and Microservices: A Perfect Combination?

In this article, we throw some light on what asynchronous messaging is all about and discuss why you should consider it for your microservices architectures.

By 
Ranga Karanam user avatar
Ranga Karanam
DZone Core CORE ·
Jun. 27, 19 · Analysis
Likes (8)
Comment
Save
Tweet
Share
26.3K Views

Join the DZone community and get the full member experience.

Join For Free

In this article, we throw some light on what asynchronous messaging is all about and discuss why you should consider it for your microservices architectures.

What You Will Learn

  • What Asynchronous Communication is.
  • Why We Need Asynchronous Communication.
  • How Asynchronous Communication is implemented.
  • Why should you consider using Asynchronous Communication for your microservices.

Best Practices With Cloud and Microservices

This is the last article in a series of six articles on best practices with cloud and microservices. The first five parts can be found here:

  1. The 12 Factor App: Best Practices in Cloud Native Applications and Microservices
  2. Microservices Architectures: Event Driven Approach
  3. Microservices Best Practices: Whey Do You Build a Vertical Slice? 
  4. Microservices Artchitecture Best Practices: Messaging Queues
  5. Microservices Best Practices: Build an Archetype

What Is Synchronous Communication?

Consider the following example of a microservices architecture:

Microservices architecture

You have Microservice1 calling Microservice2, which in turn invokes Microservice3. Suppose that Microservice3 offers a simple web service functionality. So Microservice1 can send it a request for data over HTTP, and get back a response containing the requested data.

The communication that exists between these two microservices is called synchronous communication. Microservice1 sends the request, waits for the data to be returned, and then proceeds.

Drawbacks of Synchronous Communication

This mode of communication works well when the response arrives almost immediately. However, it puts restrictions on the microservices that are involved. In order that Microservice1 be available, Microservice2 also needs to be available.

In certain scenarios, synchronous communication might not even be user friendly.

Let's say Microservice2 is down. In that case, the user who submitted the request needs to be intimated about it. You don't always want to do that. In such situations, asynchronous communication provides a better alternative.

Asynchronous Communication

Have a look at the following application architecture:

Microservices application architecture

In the picture above, we make use of a ZipkinDistributedTracingServer. Different microservices send logs that are finally consolidated in the Zipkin Tracing Service. Each microservice puts its tracing information into the RabbitMQ message queue. The server processes messages as and when they come into the queue.

In this architecture, applications communicate through RabbitMQ. CurrencyCalculationService puts its own tracing information into RabbitMQ, and then forgets about it. It does not worry about the responses coming back to it.

Now, what would happen if the ZipkinDistributedTracingServer were to go down?

The services communicating with it would not worry one bit. They would continue sending messages to the queue. When the server comes back up, it resumes processing the messages present in the queue, and saves them to the database.

Advantages of Asynchronous Communication

Let's look at a few advantages of asynchronous communication:

  • In a system that involves asynchronous messaging, the server does not need to be up and running all the time. Messages that are put into the message queue can be processed in batches, at a later time.
  • Instead of a single instance of the tracing server processing the message queue, you could spawn multiple instances to lighten the load.
  • If you use a modern version of a messaging queue, there is a good chance you get to use a replay feature. This helps in re-processing a message that initially threw an error.
  • Asynchronous communication is great for systems that require eventual consistency.

The great thing is that as long as we fix the errors and reprocess the message, the users of services that initiated the requests with errors do not even need to know about them.

Limitations of Asynchronous Communication

Asynchronous communication cannot be used if the processing needs to be real-time — i.e. if there is a hard constraint on the response time of a certain request. 

Summary

In this article, we had a look at what asynchronous communication is all about. We started with a peek at synchronous communication, and saw that it puts constraints on applications and their availability. Asynchronous communication solves the problem by causing services to enqueue requests into a message queue. A server then processes them independently, often in batches.

microservice

Published at DZone with permission of Ranga Karanam, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Tired of Spring Overhead? Try Dropwizard for Your Next Java Microservice
  • Build a Stateless Microservice With GitHub Copilot in VSCode
  • From Prompt to Running Microservice: ServiceBricks Step-By-Step
  • Dropwizard vs. Micronaut: Unpacking the Best Framework for Microservices

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!