Learning Library

← Back to Library

Understanding Asynchronous Message Queuing

Key Points

  • Jamil Spain (IBM Cloud Developer Advocate) explains that traditional application design expects immediate, synchronous processing via REST APIs, which often leads to extensive error‑handling code.
  • Message queuing is introduced as an architectural pattern that enables asynchronous communication, allowing different parts of an application to operate independently and remain functional even when other components are unavailable.
  • A “message” is simply any piece of information—such as data payloads, files, or metadata—that needs to be transferred from one subsystem to another for processing.
  • The “queue” component stores these messages in the order they arrive, delivering them sequentially to the consumer at a later time, effectively decoupling the producer and consumer.
  • Email is cited as a familiar example of asynchronous messaging, illustrating how queues let systems handle tasks later, improve reliability, and avoid the tight coupling of monolithic, synchronous designs.

Full Transcript

# Understanding Asynchronous Message Queuing **Source:** [https://www.youtube.com/watch?v=xErwDaOc-Gs](https://www.youtube.com/watch?v=xErwDaOc-Gs) **Duration:** 00:15:37 ## Summary - Jamil Spain (IBM Cloud Developer Advocate) explains that traditional application design expects immediate, synchronous processing via REST APIs, which often leads to extensive error‑handling code. - Message queuing is introduced as an architectural pattern that enables asynchronous communication, allowing different parts of an application to operate independently and remain functional even when other components are unavailable. - A “message” is simply any piece of information—such as data payloads, files, or metadata—that needs to be transferred from one subsystem to another for processing. - The “queue” component stores these messages in the order they arrive, delivering them sequentially to the consumer at a later time, effectively decoupling the producer and consumer. - Email is cited as a familiar example of asynchronous messaging, illustrating how queues let systems handle tasks later, improve reliability, and avoid the tight coupling of monolithic, synchronous designs. ## Sections - [00:00:00](https://www.youtube.com/watch?v=xErwDaOc-Gs&t=0s) **Introducing Asynchronous Message Queuing** - Jamil Spain explains how message queuing lets applications communicate asynchronously, breaking monolithic dependencies and removing the expectation of instant responses. ## Full Transcript
0:00hello my name is jamil spain developer 0:02advocate with ibm cloud and my topic for 0:05today is message queuing 0:08now as a technologist when i first 0:10started out developing applications 0:12there was an expectation that in my code 0:14that applications would 0:16process everything immediately and even 0:19when i first started dealing with rest 0:21apis that's really the expectation that 0:23i make a 0:25front end makes a rest call to a 0:26back-end through a rest api call that 0:29you're expecting a response to come back 0:31some type of response code must go back 0:33to let me know 0:34404 was not good 200 it was good but 0:38again there's an expectation that things 0:40happen instantly and i get instant 0:41confirmation that something is happening 0:44and often i wrote a lot of code to 0:47[Music] 0:48accommodate situations where that 0:50communication could not happen or 0:53or did not function uh properly there 0:56but today's topic kind of branches out 0:58through that let's deal with break down 1:00what the term message cueing actually 1:02means here so overall from a 30 000 foot 1:06view 1:07it's a definitely a architecture 1:09technique that allows you to break 1:12applications apart 1:17apps apart 1:20with what we like to call asynchronous 1:22communication 1:28i'll abbreviate that there 1:30so a secret is communication so i want 1:33my particular applications to or 1:35particular subsets to still function and 1:38not worry about the other parts there 1:40versus the other part where all my code 1:43was in one stack 1:45and uh and only in a monolithic 1:47application or when i build an 1:49application where all the functionality 1:51exists that 1:53you know one set of functions or one set 1:55of code of my application i'm just 1:57always handling a transaction off to 1:59another set of code but there is that 2:01expectation that things follow through 2:03in process right then there's no way to 2:05really kind of delay things to happen 2:06later and this is what message queuing 2:08is all about but let's break down the 2:10first part here first let's deal with 2:13the word message 2:18and as it denotes that 2:21it is really something 2:24that 2:25a piece of information that wants to get 2:27processed from one system to another an 2:29application 2:31um we'll just say subsystem from as well 2:33kind of denoted by um with that 2:36particular piece so you have data 2:40that needs to get 2:50transmitted now this could be actual 2:52data payloads actual files 2:55um it could be metadata that that 2:57references that something should happen 2:59on the other end um so many different 3:02types 3:04of 3:05data 3:07formats can be there 3:10all right and then we have the word q 3:16which q in the most simplest form 3:18refers to kind of a a line of things 3:20that are processed sequentially so when 3:22you think of a message queue think of 3:24the messages of coming into a queue as a 3:27way that kind of holds the messages in 3:29the order they are received and delivers 3:31them to the actual party so one way to 3:34think about this i know this kind of 3:36explain message explain queuing explain 3:39the overall but think about a tool that 3:42everyone uses every day 3:44email email is an 3:46excellent example of asynchronous 3:48communication and how that works i can 3:50theoretically or not theoretically 3:52actually in reality in real life i send 3:55a message out but i can wait for a 3:58response later it goes into an inbox 4:00think of that inbox your email inbox as 4:03a queue of messages that are held there 4:05and at some point 4:07the 4:08person who's going to receive it 4:10has the opportunity to look at it 4:12whenever they want if they take a longer 4:14time there's a larger list you know that 4:17has accumulated of messages that you 4:19have to read which is usually the case 4:21when i go through some of my email 4:22email boxes or for ones that i check 4:25constantly like say for instance your 4:27work email you're always constantly 4:29going through the list so you're there 4:31waiting to kind of reply back but 4:33excellent example of asynchronous i can 4:36really fill out an email compose it send 4:38it off i'm not worried about whether you 4:40received it or when you answer it but i 4:42can move on to something else all right 4:43so perfect example of asynchronous and 4:46we'll carry that example through um as 4:48well 4:49to some of the use cases here uh so we 4:52talk through those let's talk about the 4:54type of messages that occur so we've 4:56mentioned qli which is a 4:58line 5:00of messages 5:03so if i were to draw this out 5:06in in this perspective here let's do it 5:08this way let's take this green as the 5:11queue 5:15and then let's say that each one of 5:16these is going to be an actual message 5:22and so at some point you're going to 5:23have the 5:26they're going to send the kind of the 5:28message here 5:29and then at the other end 5:35somebody's going to open it up get my 5:38little envelope there all right little 5:39artwork here so the person that's 5:42putting the message on is going to be 5:43what's known as the producer 5:47and then the person consuming the 5:49message is the consumer 5:52so these are often the two profiles or 5:54roles that you can take and of course 5:56you can be the producer one time and be 5:58the consumer on another example so this 6:01one pattern here that you're looking at 6:03is more like a point to point i am 6:05sending it from one application to the 6:08other all right 6:10it could be a 6:12let's say i have a web form and you're 6:14filling out and as you complete the web 6:16form i take the metadata from that form 6:19json object 6:20i could put that on a queue to be 6:22processed later to be inserted into a 6:23database to 6:25be inserted to another system for 6:27marketing automation 6:29whatever it may be the use case the 6:30point is that i have i need messages to 6:33guarantee delivery to get there and not 6:35be dependent upon you submit the form i 6:38send it back to that other system and 6:40get a response back 6:41i can keep ingesting 6:43particular messages form submittals and 6:46keep loading those in to go from there 6:48so when you have these kind of use cases 6:50these are excellent things that should 6:52read out that hey instead of me just 6:54doing direct http connection let me 6:56think of a message cueing pattern that i 6:59can facilitate to go here so we'll call 7:02this point to point the next one is 7:04something like a publish subcri 7:07publish subscribe also abbreviated as 7:10pub sub that you will hear and this 7:12works from the capability that i have 7:15a producer 7:19let's go back to the green i'll do 7:21another cue and we'll do more messages 7:24that come in 7:26so on the pub sub model 7:28i'm going to have 7:31multiple 7:33parties or applications that are 7:35interested in getting this message 7:39as it comes through 7:44all right so pub publish subscribe so 7:47these consumers are listening for this 7:48particular i'll call it a channel or 7:51interested in this particular thread of 7:53messages that may come across so it 7:55could be that new customer signs up you 7:57may want to send something to 7:59um for a new order e-commerce order 8:02comes in you may want to send something 8:03to accounting for an invoice to go out 8:05you may want to send something to the 8:07shipping 8:08or notifications for stock or you know 8:11any multiple 8:13things that you want to kind of get 8:15through that could be something you can 8:16shoot out to kind of go and the last one 8:19i'll work through is what we like to 8:21call 8:22request reply reply requests it's done 8:25from the standard that you have a 8:27producer 8:31that's going to 8:32send out 8:35a message 8:36all right 8:38let me redraw this again really fast 8:41here i got messages that i'm going to 8:42put in 8:45okay 8:47and so 8:48this could be one way they could have 8:51one channel 8:59all right so they could be one way where 9:02they want to go out 9:04someone could consume it 9:06i could put a request out 9:08someone gets it 9:10does some processing 9:12but the response to that that they want 9:13to do 9:14i'm going to also be listening 9:17on another queue 9:22for the response to that 9:25so that could be now that all of a 9:27sudden 9:31where they're reading this request that 9:32comes through they then could put the 9:35resulting workload or whatever 9:36computation that they're doing whatever 9:38algorithm that must be done 9:40say for instance maybe your 9:43some of those patterns where you want to 9:45put your information in and look at all 9:47the offers that are out there it could 9:49be an actual search to go out and get 9:51all this information compile that back 9:53to 9:54maybe a list of object that information 9:56comes back and then i'm listening the 9:58producer is also listening to another 10:00queue to say ah the response is ready 10:04and then it takes that information and 10:05then presents it so you have 10:08point to point 10:09all right this is a pub 10:13pops up and then more of a 10:19request and reply all right so different 10:21type of messaging patterns that can 10:23occur and again i love to kind of think 10:26through things from a backwards 10:27perspective it's really about as a 10:29technologist and a solution architect 10:31sometimes you want to put your hat on 10:32where you say 10:34what is my intent what do i need to 10:37happen and that really drives what 10:38particular piece of technology can drive 10:41that particular component here all right 10:43so three patterns we identify message 10:46killing let's wrap it up with the 10:48benefits naturally of why you want to 10:50facilitate or go through the effort to 10:53orchestrate something like this and i 10:55like to bring this down to two major 10:58particular pieces here the first 11:03decoupling 11:06all right it looks like an m but it's 11:07really an eye and an n all right trust 11:09me there all right so decoupling here so 11:12what this allows me to do we mentioned 11:14the first part about breaking 11:15applications apart 11:18it allows me now to have 11:20separate items that can occur so i can 11:24in going along what we like to call the 11:25microservice pattern responsibility 11:27pattern i can dedicate one particular 11:30piece of code application to just be 11:33responsible for that one piece of work 11:36all right 11:37and if i was in a monolithically kind of 11:40code base 11:41i would have to progress things all at 11:43one time if i wanted to just work on my 11:45payments module 11:47i would also have to test everything to 11:48make sure how that affects other parts 11:50here well 11:52in this particular piece let's say i 11:53just wanted the web front end to be the 11:55web front end i don't want you to handle 11:57a lot of the processing and doing all 11:59the database connections from there i'll 12:01let other systems do that part but they 12:03can be very well at just connecting to 12:05my database connecting to my services 12:07and my systems of record anything from 12:09that so decoupling allows you to really 12:12separate things up 12:13where apps 12:16can just be 12:20apps you know just 12:22just perform their particular job 12:24here as well and naturally 12:27that will 12:31enforce scalability in your application 12:35because now you have apps that are 12:37decoupled you have teams that can work 12:38on applications i can think about my 12:40application 12:41much simpler i may have one component 12:43that i want to work on at a time while 12:45the others are guaranteed to function 12:48as is and also it allows me to add more 12:50resources to certain parts as we 12:53mentioned in the other use case earlier 12:54where i have a web form that wants to 12:56maybe 12:57handle a lot of high traffic of 12:59submitting or my front end may have a 13:01lot 13:01but i may want to wait before i 13:04process a lot of that on the back end 13:05and not have that immediate 13:07i mean want to put it through more 13:08checks maybe more 13:10detection maybe more 13:12actual code to detect for any of these 13:14things and then the use cases are really 13:16numerous here i'm trying to simplify it 13:18down to some something simple that we 13:20can digest here but 13:22this allows me to have some things that 13:24can scale out to meet demand without 13:27having to 13:29scale the whole application up so i 13:31immediately get that piece here 13:33and so from a perspective of processing 13:36of data 13:42this is great for me and i can also 13:46evolve other sections of my code to work 13:49better scale faster 13:51i want to swap in out different 13:53components all right 13:55even in my decoupling 13:57whereas before monolithically i probably 14:00am writing everything in one language 14:02because it's all one single code base 14:04decoupling gives me the ability to maybe 14:06lean on other languages for certain 14:08expertise i may have my front end and a 14:11java but my backend may be in a node.js 14:14or any other language python i can take 14:16advantage of 14:17many different other benefits that the 14:19languages can offer because again it's 14:21all about the single responsibility of 14:23work that they must achieve here so 14:27to summarize it all message queuing it's 14:30definitely for the new developer 14:32it is something to consider uh from an 14:34architectural perspective of what you 14:36want to achieve for our existing 14:38developers i started out as a lamp and a 14:40ming developer myself started out from 14:42monolithically moved into http 14:45communication between services and this 14:47is definitely a technique that i have 14:48embraced uh in my hybrid architecture to 14:51say there are some circumstances when 14:53these patterns resonate with me i'm like 14:55yes that would fit perfect to work 14:58definitely if you're getting in the 14:59cloud native 15:00being that we have things that are 15:02decoupled um 15:03or at the part that you need many 15:06different pieces to function together to 15:08connect them together message cueing is 15:10a great 15:11segue to get you immediately there in 15:13the cloud native world so definitely a 15:15great technique to try here 15:18hope this video was useful i can't wait 15:20to hear how you gonna implement message 15:22queuing in your architecture thank you 15:25for your time 15:26if you have questions please drop us a 15:28line below 15:29and if you want to see more videos like 15:32this in the future 15:33please like and subscribe