Transcript for:
Apache ActiveMQ - Introduction and Concepts

hello and welcome to another video tutorial on youtube channel of tutorialspedia.com in this tutorial i'm going to cover a very interesting topic for the integration community which is apache activemq here is a little more detail of the topics that we are going to cover in this video tutorial first of all we will have a basic introduction of apache active mq and then uh we will be shedding some light on some of the basic concepts associated with active mq and its architecture and we will be looking into several example use cases where it makes sense to use the tools and open source platforms like apache activemq and last but not least we will be looking into some other features and some of the benefits associated with active mq this is going to be an interesting and quite informative video so if you are from the integration platform or integration area or if you are interested in learning about the messaging platforms and messaging options available in the integration of multiple systems then stay tuned and watch this video you will get plenty of knowledge first of all we need to understand the problem statement that what is the main reason we need to look into the options available for the messaging platforms and what are the problems that are going to be solved by these type of platforms like apache activemq the situation that we see in different organizations currently is that organizations and their businesses are evolving rapidly and different applications and different systems are coming into the picture and they are integrating these different systems in order to fulfill their business requirements and most of these systems and applications are heterogeneous in their nature and they have their own protocol their their own semantics their own logic their own programming languages and different constructs and different type of messaging and communication protocols and formats supported by these applications so whenever we have a scenario like this where we have many applications which are clubbed together or integrated in any organization then it's become very becomes very important and critical as well as crucial for the organization to make sure that data is shared across the systems in a proper reliable efficient and scalable manner and secure manner because no application or no system in such an integrated ecosystem can work in a silo there are there are plenty of information in data that makes sense to be communicated and shared between these systems for example maybe you have an erp system maybe you have a dw h or bi systems you have some other messaging systems you have your your crm systems so all these systems will uh require to be to have a communication channel with each other to share the data between each other only then they can perform the required business tasks and operations in a proper manner so it becomes very important that organizations look into the options available to make sure that they achieve all these options and goals of reliable efficient scalable and secure communication of data between these systems and applications so in all these cases they also need to make sure that they have such a communication model which is loosely coupled and asynchronous in nature because what happens in a normal typical scenario of a synchronous communication that whenever there is some information that needs to be communicated from one system to another system then it is important that the second system of the consuming system must be alive so in case if there is no connection available or if there is a downtime or if there is a problem on the other end of the system systems being involved in this communication model then the data is going to be lost organizations in the current scenarios with critical businesses for example banking or financial systems or telecom systems they cannot afford this type of data losses so they think of an need to have some systems which can do the decoupling or lose coupling of these systems and messaging can be asynchronous so that in the case of such scenarios where there is there are certain downtime that certain failures on either side of the systems those can be mitigated and there is something in between which can deal with this type of situation so this is where we see a need for a message broker and this is the situation which can be mitigated which can be the issues related to these type of problems can be resolved if we have a message broker in between so this is what we are going to cover and this is where we will be seeing the role of apache active mq so if we look at the apache active mq this is one of the very well known jms providers in the market and it is in the market for quite long and heavily used and when we talk about apache active mq this is known as a jms provider when we say it it's a jms provider what does it mean basically jms specifications are there in the market and there are different providers whether they can be open source or proprietary which are actually implementing those gms specifications and then they are they are acting as jms providers so when we talk about jms providers they fulfill the requirements as per the specifications of jms they are complying to the gms specifications and on top of the jms specification they are the tools or they are the softwares or the software programs which are providing the needful uh functionality uh which serves the required purpose as a message oriented middleware so if we see in the market there are many options available some of them are open source as an example we have this apache active mq and we do have some options which are proprietary as well for example we have another well-known jms provider which is tipco ems provided by tipco software when we say about when we talk about apache active mq we say that it's a message oriented middleware which means that it's going to act as a middleware or it's going to act as a message broker uh these two terms you can use assigner names as underneath this of the same purpose and what happens is that it acts as a broker in between the producers and the consumers of the messages and all the information that's going to communicate that's going to be transferred from the producers to the consumers using these message brokers will be in the form of messages these messages have their own structure which we are going to cover in subsequent uh slides in this tutorial and when we talk about apache active mq this is this tool fully supports asynchronous or in other words loosely coupled or decoupled communication as i explained before that what happens in case of this type of message brokers is that producers produce the message they send the messages to the broker and then they don't care whether the consumer is able or alive at the same time to receive the message or not there can be different options available in order to persist this data and then come in then asynchronously the clients are the consumers or subscribers are going to consume or receive the data from the message broker and process it so there is a decoupling between the producers and the consumers with a message broker in between this is very high level overview of apache active m2 i'm not going into much of the nitty gritties as there are a lot of other basic concepts associated with apache active mq which we are going to see further in subsequent slides so now that we have a basic understanding of what exactly a message broker is and what why it is used for and what kind of problems it's going to resolve or solve let's now look into some of the basic concepts of are some of the basic constructs which are part of apache activity so when we talk about the basics of any of the message broker then cues and topics which are the destinations those are one of the major con among the major constructs of any of the message broker so when we talk about cues cues are used for point-to-point messaging or point-to-point communication so these are just the placeholders or the message holders within the message brokers so what happens is that whenever we want to have a point-to-point communication or whenever producer is going to produce a message which needs to be consumed by only one consumer in that case it's going it's going to use a queue so queue is fifo based works on fifo based architecture first in first out although there are some options to set the priority of the messages as well but what happens is that the producer produces a message if it provides the name of the destination in the form of a queue and message is sent to the queue and once it reaches to a queue a queue is going to be on the message broker and depending on some other features which we will see later it's going to be persisted or not and then this message is going to be consumed by the consumers which are already acting as consumers or subscribers to the same queue so in this way a message sent to a queue is going to be received or consumed by only one queue but contrary to this whenever we have a requirement for a broadcasting scenario and we want to broadcast a message and this message is going to be subscribed or consumed by multiple subscribers then we need we have another option available in case of apache activemq which is topic so it's another kind of destination on the message broker so in case for example let's suppose you have some type of notification that you want to publish and you want multiple subscribers who are interested into that type of notifications that they should they all should be receiving that notification so what you will be doing as a producer that you will probably you will produce the message and you will just publish it to a topic so once it this it's published to that topic then all of the subscribers who are subscribed to that particular topic are going to receive that message whoever are available there is another concept about durable subscribers so what happens is that we will see when we will explain subscribers or consumer that if it's a durable subscriber then there is another mechanism that even if it's down it's going to receive the message later then another concept that we have to discuss is producer or publisher so whenever we use cues we we call the the message produce the one who the party which is producing the message is sending to the queue as producer and whenever we we use topics then we use the term publisher for the message producer so you can use both publisher or producers but in general for the topics we use the word publisher and for the queues we use the word producer so the the the functionality that is provided is sam both are producing a message so they are the producing applications which are producing certain type of messages which other parties are interested in and they will uh send a push the message to the queues are the topics on the active mq a message broker so whenever producer produce the message after that they send a message with certain properties and certain conditions certain header information as well which we will see when we will be discussing about the messages and then the next important concept is consumers are the subscribers so whenever a message has been published by the publisher on the producer and it is sent to a cue or a topic then the message has to be consumed or subscribed by some other parties who are the uh on the on the receiving end of these message brokers so these consumers our subscribers will be listening or will be consuming the messages from those queues or other topics respectively and they are going to receive the message and then whatever they want to do with that message they can do on their own site and next topic next important concept is messages so all the things that we are discussing here about the message brokers messages are the key ingredient of this whole picture and messages are what being communicated between the producer and the consumers through a message broker so when we talk about a message in activemq it consists of three uh three parts it has headers it has properties and it has body headers and bodies are always there and properties are optional for in the header you can provide certain information for example you can decide that this a particular reply to queue should be so should be shared so in that case this you will be specifying that whenever a message has been published to you from to the message broker and then when reply will be coming it should be coming to which particular reply queue and also you have you can have additional header information like you can specify the jms expiration for the message that the message should expire after how much time you can have the priority also defined in the header and when we talk about properties these are the optional properties that you can specify so whenever you specify certain properties for the message then what happens is that on the client side they can use the jms selector as well so this serves the purpose of filtering the messages let's suppose that you are going the producer is going to produce a message and sending to uh sending to a queue or a topic and it it provides a property uh for example account type as an example and let's suppose that account type is current are saving so there can be a subscriber which is interested only in the saving accounts or only in the current account so what happens is that the client is going to use the jms message selector option using this property and it will be picking only those message which fulfill the required criteria as specified in the properties and then when we talk about the body of the message the body can be of many types including the primitive types for example it can be a string or even if it can be a complex type of body maybe it can be a java object it can be json it can be xml you can have any type of body for your jms message there are certain type of certain types which are supported which you can see in the documentation of your the jms specification are of the jms provider the last thing that we need to discuss about the basic concept is message persistence so persistence plays an important role in terms of reliability and efficiency of your jms message broker what happens is that whenever you publish a message by default persistence is enabled in case of apache active mq so whenever you are publishing a message and if you are setting the persistence property what happens is that on the jms broker this message is going to be persisted into the into the storage which our storage is configured so in that case there is less of a chance of any data loss just in case if the message broker goes down so you have messages persisted in a persistent storage and in case of failures at the message broker whenever message broker comes back it's going to still pick the messages from the persistent storage and continue to serve the messages to the consumers so this is an added layer an added functionality of reliability associated with messy brokers and another important thing is that the good thing about gm apache active mq is that it's up it has a support for non-jms clients as well using different protocols and different options for example you can use rest api it can it also supports some of the protocols like amqp mqtt s2mp as well so different type of for example if you have a flat text you can use stomp and you can use the other protocols as well so what happens is that no matter what kind of clients you are using if that client is nuts for example if you are using a client which doesn't have a support of mqtt but it does have a support of amqp then you have the liberty to use amqp and if it has a support of rest api which is available most of the cases of the clients be it any if you are building or implementing your client in any programming language mostly of course the rest api support will be there and additionally these other protocols which i mentioned here are also supported in most many of the messaging clients so you have a liberty and you have an option that whatever type of protocol or the format you want to use as a client you can use so it and it provides more flexibility whenever you are going to implement or whenever you are going to integrate multiple different type of heterogeneous systems using apache mq as a message broker so now let's talk about some of the use cases these are just example use cases in actual you can have hundreds of scenarios or use cases where you can use the power of active mq and do the need for integration and get the messaging platform ready but i will just explain a few example cases here first case is web portal let's suppose you have a very uh advanced and complex web portal where you need some sort of asynchronous loosely coupled or decoupled messaging across the modules so in that case of implementation if you have active mq as a message broker in between it can really help you a lot to ensure that there are no uh single no no such delays are there are no such fates because of the synchronous calls rather everything is asynchronous in nature and one of the module producing a messages is just producing the message sending to the destinations or queues or topics on your apache active mq and then the other module is going to receive a message you might have some workflow mechanisms as well where you are just producing the messages at one one level of your workflow and then there is another step where someone else is going to take the messages from there maybe another application or maybe another module within the application and it's going to consume and it's going to process the message and then it might be producing another set of messages and those are going to be sent to another queue or a topic and then the sequence continues and you have uh additional consumers and producers working uh in an asynchronous manner so this is just an example where you can utilize the power of apache active mq the second example scenario is you have order processing system and you have an integration of different systems of different applications and system within within your order processing platform so let's suppose that you have some application which is receiving the orders from the clients then you are going to just push those orders to another system which is going to do the required processing of that order validating those orders and after that you might have another system which is going to do the required back-end processing for those orders and then you might have some of some other platforms or systems for the shipment for the payment handling these are just some some of the naive examples that i just i'm throwing here and you can have this type of scenario where you you can use and you can utilize activemq as a message broker then another example is that let's suppose you have multiple partners or clients which you have to integrate and you have some messaging and broadcasting systems and you want to make sure that whenever you have certain announcements whenever you have certain notifications whenever you have certain alerts then you want to make sure that all your partners or clients who are interested in those messages are those type of broadcasting system notifications you want to use some sort of messaging platform which can serve the purpose so in this scenario as well you can use a message broker apache activemq and what's going to do is that you are going to produce the messages or you are going to push the messages publish the messages to the topics and then all those parties which are interested in those messages are going to receive the messages from the respective topics or cues and then they are going getting notified so this is another example scenario where you can use apache mq another example is related to internet of things iot so uh in case of iot mostly uh it's preferred to use some streaming systems like apache kafka but still you can utilize apache active mq as well and active mq can be used in this scenario so what happens is that iot devices are going to send sense sensed sensor based notifications or whatever information and they are communicating it's going to be published since apache activemq does support different protocols so in that case using whatever protocol is supported those messages are going to be published or pushed towards the jms destinations topics accused and then going to be received by the receiving it so this is another scenario where you can utilize apache so basically the core of all the discussion on this slide is that any asynchronous processing system that you want to implement or you want to have in your organization you can use apache active mq for that purpose so whenever you have a requirement of asynchronous communication model first first thing that should come into your mind is that you need a message broker and whenever it comes in your mind that you need a message broker then the second filter comes in your mind or decision item comes in your mind is whether you want an open source or you want a proprietary system and whenever you say that you need a open source message broker then apache active m2 is going to be one of the major players in the market that you will look take into consideration so now that we have covered some of the basic concepts as well as the use cases of apache active mq now let's look into some of the benefits that are associated with the apache activemq like any other message broker apache active mq just does come with a lot of features and options available and there might be some shortcomings as well associated with any of these this type of products but here we are just going to cover the benefits of the other good things that are associated with apache active mq the first thing is loose coupling as i explained before that in this case of having a message broker in between you have a mediator or you have a broker in between the producers and consumers and producers and consumers are no more tightly coupled so producers can continue with their work once they have produced a message and sent it to that broker they don't care and don't wait for the consumer side to consume the message and this is contrary to a typical point to point direct communication model where you have a producer producing a message and sending a message in the synchronous manner to the consumer consumer is processing receiving the message producers thread is in a wait state and it waits for the consumer and it will receive a response or acknowledgement from the consumer or else it will time out so that is a typical synchronous application messaging behavior but here you have a loose coupling between the producer and consumer which greatly improves the performance because there can be scenarios where either of the two like your producer or your consumer they might be slow they might have certain slowness for any of the reasons speed network reason the application reasons or be it some other scenarios because the data or the messages that are being sent from the producer to the consumer might be uh the speed are the throughput on either side might be higher so in those scenarios if you are if you are using a loose coupled broker-based scenario then you you don't have a problem because you have a broker in between which is going to handle these type of things messages are going to be persisted there and your consumer is going to consume the message as at its own speed without having any impact on the producer side the second good thing benefit associated with excuse me for apache active mq is that it supports for multiple formats and multiple protocols i explained below before that you have liberty to use different available protocol options as well as you can use rest api so you don't have to tightly force all of your clients are all little producers that you have to use a particular xyz protocol no they have liberty they have option they can use different protocols and then they still they are able to integrate themselves with the message broker the third thing is that reliability is one of the major positive features associated with activemq so what happens is that you have the option of persistence so at the broker level you achieve reliability by two means either you can have a cluster of brokers uh you can have multiple brokers in ft or lb mode so you have a fault tolerance using this type of horizontal scaling and but at the same time the message persistence does provide you another layer of reliability because whatever messages producers are producing and if they are send with a persistence property set to true then messages will be stored into a persistent storage so in worst case scenario even if you have single broker and if it goes down the messages which are persistent in the persistent storage will be still there and whenever message broker goes up again it's going to continue serving and sending those messages to the clients and the second option is the option available for jms specifications which is durability of the subscriptions so what happens is that normally whenever a message is sent to a topic and only those subscribers which are live at that time will be receiving the messages and any of the subscriber for that topic who is not up at that particular time will will lose the message and will not receive the message but if we have a durable subscriber so whenever we are creating a subscriber if we set it as durable subscriber then for that for durable subscriber uh message broker will hold the message and even if it's down one of once this subscriber comes back and it's live it's still going to receive the message so it's an added reliability mechanism that you can enforce in the scenarios where you have highly critical data which you cannot afford uh losing the next thing is that this active m2 supports provide scalability options so you can have vertical as well as horizontal scaling when we say horizontal scaling it means you can have a clustering you can have multiple jms brokers and when we say vertical scaling of course whenever you have a you have a broker or you have a set of brokers you can always increase the the overall cpu memory and whatever resources they are using and you can fine-tune it to make sure that it is able to perform well even if without increasing additional brokers into the cluster so these are some of the benefits that are associated with active mq of course there are many other benefits as well at different levels that you can think of when we talk about active mq but i just covered some of the major items so that's it from this video tutorial and i did not go into much of the nitty gritties as uh i will put the rest of the things up to you if you are interested to learn more you can refer to my website tutorialspdr.com for not only about mq but also about apache kafka as well as tripco mulesoft and other integration platforms you can learn and you can go through different video and text tutorials there and you can get back to me if you have any questions and don't forget to subscribe to the channel as i will be uploading more videos practical videos about apache active mq as well as other technologies in future thank you very much