c++ - Rabbitmq vs Apache QPID - Stack Overflow
If you do this, please make sure to attach a date to the article as well so users are RabbitMQ vs Apache ActiveMQ vs Apache qpid by Bhavin Turakhia (May. I'm willing to bet that AMQP/ won't happen in or unless it's a rollback . a dump of the internal structures of a single implementation (Apache Qpid). networking protocol has to evolve to keep up to date with new technological . For example, compatibility with the Java Messaging System ( JMS) is another of. ActiveMQ, Qpid, HornetQ and RabbitMQ in Comparison. Thomas Bayer. By: Thomas Bayer Date: 04/11/ Should we continue to use established brokers such as the ActiveMQ or try a more modern one? This article attempts to answer.
If a piece is owned by a committee, the incentives to improve it and protect it are just not the same. AMQP is one over-sized package owned by a committee. Each layer of the stack could be redesigned by anyone. Think of SASL security mechanisms. You want to make a new one? It's clear where, and how, to do the work. Each piece of work could be properly tied to its authors, persistently.
Credit, you might think. But blame and responsibility seem more pragmatic mechanisms for quality. There could be a proper process, an etiquette, for changing any given piece. That's not feasible with huge pieces of work. The lack of a polite change process seems to have affected many participants, so not only does the protocol get progressively worse, we lose those people best able to fix things. It is an incompetence-complexity tarpit, and AMQP is sinking into it like a lost beast. A healthy change process, in software and in standards alike, is tightly linked to ownership and works as follows: You need a change in a layer you depend on.
You identify the breakage or lack. You identify the piece that is broken. You identify the author or authors of the piece. You notify them of the problem and ask for a solution. If you are able to, you propose something yourself. You wait for a reasonable time and hope your question is answered. If necessary, you bribe, blackmail, cajole the authors. And, if the authors don't respond, insult you, mistreat your contribution, or otherwise behave anti-socially, you take their work, fork it, start a flame war, and try to win people over to your - you hope - improved version.
At that point you become responsible for that piece. You saved it, you have to feed it. This is how successful open collaborative of any kind works: A good modular architecture that splits a large problem into smaller pieces that collaborate and compete in clear ways defined by formal contracts; A clear ownership model in which every piece is ownable and owned; An etiquette for changes that relies on and respects ownership, while making it possible for forks to be made freely.
The goal is to take the natural tendencies to compete and collaborate, and turn these into useful drivers rather than reasons for conflict. The same rivalry that can spawn a thousand flames can drive competing teams to superb achievements. But only if the social architecture is done right. I've said that AMQP is a social, not a technical, challenge. Social architecture goes much wider than organization of the Working Group.
It extends into AMQP users, and contributors outside the core specification developers. So far in this article, I've shone the light on some of the less fun parts of how AMQP is being made. After two years of public AMQP releases, where are these contributors? Where is the community? Where are the forums, the blogs, the FOSS projects, the normal symptoms of a healthy standards process?
Their almost total absence is perhaps the most solid sign that AMQP is not in a good state. The market is rarely wrong, and while many people appear to believe in AMQP's potential, few or none of those thousands of potential protocol engineers have signed up and put their time and money into the specification game. The spec is being developed by software engineers working for large firms, not protocol specialists.
On-line communities, it seems obvious, grow. What is less obvious is that they seem to grow as a response to social challenges.
For example, I'd argue that the Wikipedia community is strong and confident because it is continuously confronted by trolls, spies, liars, and manipulators, and it's always developed ways of beating them. The fact that anyone can edit a Wikipedia page and thus make a mess of someone's neat work is not a problem. Rather, it is the fundamental driver of Wikipedia's success.
Edit wars create emotions that bind the community together. So from one point of view, the AMQP community needs problems to solve, preferrably social problems, not technical ones. In other words, exactly the kinds of problems that have beset AMQP's progress. The lack of a community is both symptom, and in my view, contributing factor. There is almost no AMQP community, only a self-selected and weakly diverse expert group. If any excuse was needed for exposing AMQP's inner turmoil and thus embarassing people, it is this: And of course, social issues, the physics of people, are never tidy or painless.
However, the big difference between AMQP and Wikipedia is that the latter is a meritocracy where anyone can join in, individually, and be promoted on the basis of their proven works. AMQP is a club of businesses, one has to be invited, and one represents one's company, not oneself. The rules for joining and for voting are being relaxed somewhat but it's still a tortuous process.
At a certain stage the number of AMQP participants was restricted simply because the effort of sending around packs of contracts was too great. The main reason for this heavy layer of contracts was fear that one of the participants might introduce patented technology and thus try to capture some of that lovely natural monopoly efficiency. It's a reasonable fear, but there are simpler ways to resolve it.
First of all, multilateral agreements - between many parties - are not scalable. AMQP needs to be hosted by a proper not-for-profit organization so that agreements can be one to many, and the cost of welcoming new participants is linear, not exponential. Secondly, the contracts can be a lot simpler. Basically they are a promise from a contributor - individual or organizational - to whatever entity owns AMQP to not patent anything in the specification, and not introduce anything that is patented, except under condition of a royalty-free, global, irrevocable license to anyone wishing to use it.
There is some stuff about copyrights and trademarks, and that's it. Now, agreeing on policies for making changes and voting on them is obviously a good thing. Putting these into the one place it's almost impossible to change is not a good thing.
Policies need to be lightweight and easy to improve. As it is, the heavy contracts we all signed about the mechanisms for collaboration have not helped a jot when it actually came to resolving conflicts. Apart from the procedurable barriers to entry, AMQP's technical complexity makes it very hard for anyone not already in the loop to take part. I will repeat an old joke - if you know what any part of the latest AMQP specification means, you were probably the author.
Rapidly increasing complexity is a sign that the process is failing. It felt like fear of scrutiny: At iMatix we're used to setting up community infrastructure. One of my projects, which is hosting this article, is Wikidot. Community infrastructure is my business. For AMQP we tried, repeatedly, to set up a simple and pleasant infrastructure, and each time we were stopped by voices on the Working Group who felt there were better ways - which never emerged.
When it takes thirty to sixty seconds to make a single change to a wiki page, you can be sure that people stop contributing really quickly.
A cynic might add that the slow SSL interface and multiple login pages only bothered people outside that particular company, not engineers from inside it, so that it was not surprising that drafts of AMQP increasingly came to reflect the views of a single player. One of the ways to capture an emerging standard is to capture the processes, and infrastructure behind it. AMQP is not safe from this, but it must become so.RabbitMQ or Qpid Dispatch Router pushing OpenStack to the edge
An entity that is independent of vendors and their antagonism towards outside expertise. Suitable funding to pay for community development, system administration, etc. Conscious marketing towards pioneer experts who like new technologies. Events, newsletters, forums, blogs, and so on, aimed at the community. And above all, a simple way for independent experts to participate in the process, and contribute with some confidence.
Which brings me back to the "Pain is a Bad Sign" principles of a good modular architecture, ownership rules, and a clear and ethical change process, all of which are lacking in AMQP and will exclude any community participation except at the margins.
If I was giving advice to the AMQP Working Group I'd suggest them to focus less on writing specifications, and more on building the successful community that can write the specifications. The cardinal sin of any expert is to believe in their expertise. We succeed only when we recognize and expect our limitations and compensate for them. It's our mistakes and failures that should teach us the most. And speaking of failures, the basic AMQP design, which I am responsible for, has very large bug in it, a massive design flaw based on wrong assumptions and driven by premature optimisation.
No-one seems to have spotted this design flaw, perhaps because all the engineers still working on AMQP share the same wrong assumptions. An insufficiently diverse group sometimes can't spot the obvious. In the next section I'll explain what this flaw is, and how fixing it will open the door to a faster, simple, and altogether more enjoyable AMQP experience. Premature optimisation is the fast lane to hell While I'm not going to go into technical detail on AMQP partly because I've not tried to follow the tidal wave of changes in the familysome design decisions are fundamental, and if they are wrong, they affect everything.
If you've looked a little at AMQP, you'll see that it's a binary protocol. This means that methods like Queue. Create are defined as binary frames in which every field sits in a well-defined place, encoded carefully to make the best use of space.
Binary encoding of numbers is much more compact than string encoding. Because AMQP is a binary protocol, it is very fast to parse. Strings are safe, since there is no text parsing to do. Overall, AMQP's binary encoding is a big win. That last statement has been proven to be wrong. Evidence shows that AMQP's binary encoding is a fundamental mistake.
And it's a mistake I take full responsibility for: To understand why I'm admitting this, let's look at the advantages, and costs, of this approach, and let's deconstruct those basis assumptions that I claim are now proven to be wrong. Finally, let's compare this with an alternative approach based on more accurate assumptions. Advantages of binary encoding: It is faster to parse than a text format. It is safer to parse strings. The codecs can be fully generated.
It is easy to process in silicon. Costs of binary encoding: You need codecs in the first place. It creates endless incompatible versions of AMQP. It is more complex to understand and use than string encoding. There is a lot of emphasis on data types. Even the simplest client API is significantly complex. Now, a fast, compact wire-level encoding is surely worth the hassle. So conventional AMQP wisdom is that the costs of binary encoding are a necessary price to pay if one wants a fast, reliable protocol.
Our view was that we could not hope to achieve the necessary performance over a text-encoded protocol like HTTP. The main assumption underlying AMQP's encoding is that it's necessary for performance reasons speed of parsing, compactness of data. If I can show that this assumption is wrong, I have demolished the main justification for binary encoding. Here is a pop quiz to test your knowledge of protocols. What is the fastest common messaging protocol, built-in on every modern operating system, integrated into every browser, and capable of saturating ordinary networks?
In fact if implementations of this protocol were not dependent on reading and writing everything to disk, they would probably score as the fastest messaging application every designed. The answer is FTP, the humble file transfer protocol, beloved of network engineers who want to check whether a network link is configured for Mbps or 1Gbps: FTP is capable of shoving data fast enough down the line to prove without doubt how fast the network is.
Now, the interesting part and the reason for my question. What is special about FTP that lets it transfer data so rapidly? And what lessons does this provide for AMQP? Incidentally, the origin of my views on AMQP performance come from our work on ZeroMQ, a messaging fabric that can transmit millions of messages per second.
FTP wins because it uses one connection for control commands, and one for message transfer. This is something that later protocols, like HTTP, did not do. Faster and simpler are desirable features. AMQP's main assumption that binary encoding is needed can be broken into more detailed assumptions, each wrong: That it is neccessary to optimise control commands like Queue. The assumption is that such commands are relevant to performance. In fact, they form a tiny fraction of the messaging activity, the almost total mass being message transfer, not control.
That control commands need to occupy the same network connection as messages. The assumption is that a logical package of control commands and message data must travel on the same physical path. In fact they can travel on very different paths, even across different parts of the network. That the encoding for control commands and for message transfer need to be the same.
In fact, there is no reason for trying to use a single encoding model, and a big win from allowing each part of the protocol use the best encoding, whatever that is. What AMQP should have done, from the start, was to use the simplest possible encoding form for commands, and the simplest possible encoding form for messages.
I can't over-emphasise the importance of simplicity, especially in young protocols that have to support a lot of growth. The simplest possible encoding for commands is in the form of text, with for example the 'Header: This is trivial to parse using regular expressions. Attacks on this kind of encoding are in the form of oversized strings, and they are easy to deal with.
There are no funny data types, everything is a string. Using a simple text encoding for commands releases AMQP from many of its shackles: It becomes obvious to developers. It becomes easy to have backwards compatibility.
It becomes easier to write clients. It becomes easier to debug and test AMQP test cases.
Does the text parsing create a performance penalty? Yes, but it is absolutely irrelevant - and I can guarantee this - in the overall performance question. What then is the simplest possible encoding for messages? AMQP defines a rather impressive envelope around messages around octetswhich may be fine for large messages and low performance goals, but is bad news for small messages and high throughputs.
When we developed ZeroMQ, we wondered just how small the message envelope could get. The answer is quite surprising: The simplest message encoding has a 1-octet header that encodes a 7-bit size and a 1-bit continuation indicator: We can of course define other encodings, each with their own cost-benefit equations.
Now, a necessary question is, "how do we mix those simple text-based control commands with that simple message encoding?
Apache ActiveMQ ™ -- Articles
We can wrap binary messages in textual envelopes. This single-connection design looks simpler but in fact becomes quite complex, and it is inefficient. We can use distinct connections for control commands and for messages, like FTP. This is simple but means we need to manage multiple ports.
We can start with a simple text-based control model and switch to simple binary message encoding if we decide to start message transfer. This is analogous to how TLS switches from an insecure to an encrypted connection. I prefer the last option. In any case, it is useful to separate control and data. Mixing them, as AMQP does today, creates some extraordinarily delicate problems, such as how to handle errors that can hit both synchronous and asynchronous dialogues.
AMQP's exception handling is an elegant solution but wouldn't it be nicer to have something more conventional? There is a concept I call "natural semantics". These are simple patterns that Just Work. Natural semantics are like mathematical truths, they exist objectively, and independently of particular technologies or viewpoints. They are precious things. The AMQ exchange-binding-queue model is a natural semantic. A good designer should always search for these natural semantics, and then enshrine them in such ways as to make them inviolable and inevitable and trivial to use.
The natural semantic for data transfer is optimistic asynchronous monologue in which one party shoves data as fast as possible to another, not waiting for any response whatsoever. I'll answer the question of "what happens if data gets lost" in the next section. AMQP does allow both synchronous and asynchronous dialogues but it's not tied to the natural semantics of control and data. The natural semantics are weakly bounded, insufficiently inevitable.
And these weak boundaries are fully exploited as people experiment with asynchronous control and synchronous data, creating unnatural semantics. HTTP is slow because it uses the wrong semantics for data transfer.
Wrapping data in control commands, as BEEP does, would make the same mistake. Using two separate connections is good, because it cleanly separates the two natural semantics. But if you've ever implemented FTP servers and clients I have, and they are evil in this respect then you'll know that FTP's port negotiation, which is designed to cross firewalls, is a big part of the problem. While we're at it, let's forget the whole notion of connection multiplexing, called "channels" in AMQP.
This solves HTTP's problem, where clients open and close many connections in parallel as they fetch the components of a web page. AMQP clients open one connection and keep it open for ages. Multiplexing solves a non-issue and does it quite expensively. Let me wrap this up in a single statement: I am so sorry! In my defense I'll point out that no-one else has pointed out the flaws in these assumptions, so they cannot be that obvious.
ActiveMQ, Qpid, HornetQ and RabbitMQ in Comparison
In the next section I'm going to point at an even larger assumption, one that underlies the whole AMQP vision, and one that I've always felt uncomfortable with. I'll argue that it too is flawed. On avoiding special cases I've looked at what I believe are the reasons why AMQP is too complex, why it has been painful for most of those involved, why there is no community around the protocol, and how and why as the original AMQP author I almost totally misdesigned the wire level framing.
These may seem like serious charges and admissions, but they are all both natural and recoverable. I have to admit that my views on this particular topic pit me directly against others in the AMQP Working Group, who must think I am either naive, trollish, or just wrong-headed. Yet I've been forced into my particular point of view, which was not where I started with AMQP, by the weight of evidence.
Mainly, I'll argue that the vision of AMQP in which a central server reliably stores and forwards messages is wrong, based on two mistaken ideas. One, that we de-facto have a central server. Two, that we have a single reliability model.
I'll try to explain where these ideas came from, and why I think they are wrong. AMQP has many sources of inspiration but most of all, it was inspired and shaped by the notion of a central server providing functionality roughly equivalent to JMS, the Java Messaging System.
The Kevlar vest was inspired by the sub-machine gun. The AMQ model of exchange-binding-queue is the Kevlar to JMS's "destination", which an example of a perhaps perfectly unnatural semantic sold as "Enterprise technology". We were trying, in part to make it easy to support JMS later, and in part, just reusing concepts that we assumed worked, or at least worked well enough to take us through to the next version of the protocol. Let me recap some of the relevant assumptions we inherited from the JMS specifications and the JMS products we felt we were competing with: That there is a central server or fail-safe central cluster of servers.
This is conventional wisdom, especially in the Enterprise, which seems to like big central boxes. That the protocol must support "fire-and-forget" reliable messaging. This is a logical assumption, since if reliability is not in the protocol, every implementation will make its own version, and we won't get interoperable reliability.
That there is a single, ideal model for reliability, which looks a lot like relational database transactions, and that this single model can handle all application scenarios. That such reliability must be implemented in the central server s. This is logical since full reliability needs things like horribly expensive Enterprise-level storage area networks SANswhich obviously need to sit in the middle somewhere. That such reliability is implemented by conventional transactions, operating on published messages and on acknowledgments.
This is a direct lift from JMS, which represents the way successful products like MQSeries do it, and so must be right. That these transactions must survive a crash of the primary server, and recovery on a backup server. This is just a consequence of the previous assumptions.
But it's the stinger. What is hard is making centralized transactions that can survive a server crash. In other words a large part, perhaps most of, the work done on AMQP over the last two years has been focussed on getting this "Enterprise level" reliability. My best understanding is that this work has been driven by large corporate almost-clients who absolutely insist that they cannot commit to AMQP excuse the pun until it delivers this very desirable functionality.
It feels a lot like belief-based investment, rather than evidence-based investment. Transactions - the conventional unit of reliability - also fit very uncomfortably on top of asynchronous message transportation, which is the core of AMQP.
Just when is a message delivered? Is it when the exchange has routed it, when it's been put onto a queue, or received by an application, or when it's been processed and acknowledged?
Migrating from RabbitMQ to Amazon MQ
What if the message is routed across multiple servers in a federation? What if we want to use a multicast protocol? If reliability is going to be built into the basic protocol then it must have answers to these questions. I have not seen answers. If we look at the latest drafts of AMQP, they seem to be telling us clearly, "this problem is too hard to solve". Some of the AMQP editors seem still to be optimistic but I don't see the basis for that optimism, and as far as I can see, AMQP is not going to deliver "fire and forget" reliability until there is a radical change of strategy.
I'm not against the notion of fire-and-forget. But putting this into the wire-level protocol has not worked, despite effort that is now several orders of magnitude greater than the work of originally designing AMQP. When I wrote about reliability in the section, "Keeping it simple", I was referring to this.
A high-level feature demand that creates disproportionate complexity at all levels of the protocol must be questioned, especially when it turns out to be approximately impossible to implement. My view is that trying to make perfect reliability in AMQP, today, is mixing innovation and standardization, which is like mixing petrol and fire crackers.
AMQP is not, though it should be, partitioned in such a way that reliability can be layered later on top of a more basic protocol that is locked down today. Big changes make a mess of everything, and that mess cannot be cleaned up, since it is structural. There may be several reasons why it has been impossible to make reliability work in AMQP. Perhaps the very notion is flawed.
Perhaps we've taken the wrong approach. Perhaps the lack of architecture in AMQP makes it impossible to do such work, because every change breaks numerous other things. All these may apply to some degree, but in my view, the reliability issue has been impossible to solve purely on a technical level because we've been trying to solve a restricted special case. Perfect interoperable reliability may be solvable, but only if we deconstruct our most basic assumptions about the role of the AMQP server, about centralization, and about what "the protocol" is.
We'll start by looking at performance, and the impact of a central server on performance. Forcing all messages to pass through a single point creates a performance bottleneck that gets worse as the number of clients increases.
It adds two kinds of extra latency: Second, the cost of waiting as messages queue up to be processed. As volume through a central server increases, latencies get exponentially worse and worse, which is a nightmare for serious messaging users, who need reliably low latencies. Protocols like IP have similar problems and they solve them brutally: But since AMQP is aiming to make a fully reliable protocol, this is not an option, so we are left with an unsolvable problem.
IP's solution has several desirable consequences.
What is wrong with AMQP (and how to fix it) - High Performance Solutions
It lets any point on the network take charge when it is overloaded. It lets network traffic flow around failures.
It lets networks scale to anything from zero to hundreds of intermediate routing points. IP hopes data will get through but does not assume it will. AMQP thinks data will get lost but believes it can prevent that from happening.
A central server that routes messages also halves the network capacity, since every message must be sent twice: So pumping messages through a single central point is bad for performance and scalability.
But from a more general network design perspective, it is a rather special case: If we believe in centralization, that means we want the number of switch points to be exactly 1. But belief must take a back-seat to evidence. Do we have cases where N is not 1, and are these cases relevant? Certainly, we have real-life cases where N is 2 or 3, so-called "federation" where one server acts as a client of a second, which may itself be the client of a third.
Federation is an essential architecture: We can look at ZeroMQ, which pushes routing to the publisher edge, and queueing to the consumer edge. With no central server, and with a lot of careful coding, ZeroMQ can hit speeds that are an order of magnitude greater than any AMQP implementation.
And as you'd expect from a peer-to-peer model, it continues to scale smoothly as the number of peers on the network grows. I don't believe performance is optional: After all, we spent a great deal of effort optimising wrongly, it turned out other parts of the protocol.
So AMQP's reliability model, if it ever sees the light of day, will be useless for every one of the real deployments we have seen. This should be enough to convince but I'll present one more reason why I believe reliability should not be built into AMQP's basic protocols. Reliability is not one thing. The kind of reliability we want in a particular case is closely tied to the kind of work being done.
We must start any design discussion for reliability with a clear statement of what kinds of messaging scenarios we are considering.
- Migrating From JMS to AMQP: RabbitMQ, Spring, Apache Camel, and Apache Qpid
Messaging is not one model, it is several, and each has cost-benefit tradeoffs, and each has a specific view of what "reliable" means. To give a non-exhaustive list: The request-response model, used to build service-oriented architectures. A caller sends a request, which is routed to a service, which does some work and returns a response. The simplest proven reliability model is a retry mechanism combined with the ability at the service side to detect and properly handle duplicate requests.
In this model, if data is lost, clients simply wait for fresh data to arrive. A good example would be video or voice streaming. The reliable publish-subscribe model, used when the cost of lost data is too high. In this model, clients acknowledge data using a low-volume reply back to the sender. If the sender needs to, it resends data. This is similar to TCP. Each of these looks like a distinct reliability protocol, each with different semantics and different interoperability, which tells me that they need to be layered on top of AMQP, rather than solved within it.
Trying to solve reliability within AMQP means either that it will only solve one of the several cases, or it will try to solve them all, and be over-complex.
Let's recap what's wrong with centralized reliability: It does not handle the case where there is no server in the middle. It does not handle the case where we federate servers together.
It does not fit on top of an asynchronous message flow. It wrongly assumes we need a single semantic model for reliability. It has proven approximately impossible to design. It has broken AMQP in many ways. There is no evidence it is the best model. There exist other designs that are simpler and proven. Other successful protocols don't try this. Thus we come to the inevitable conclusions: The basic AMQP message transfer protocol should not have any semantics for reliability, acknowledgments, transactions, etc.
It should imitate IP and be an optimistic, cynical protocol. Different types of reliability should be layered on top of this basic messaging protocol. It is safe to assume that different types of security should also be layered on top of the basic messaging protocol.
My conclusions will upset and annoy people who have spent a lot of time and money on trying to make the AMQP wire-level protocol implement perfect reliability. In my defense, I will say two things. First, this is not a new discussion. We explained it in early when we started our work on peer-to-peer messaging. Bringing the topic to a wider public seems necessary and overdue. Second, given the choice between annoying some people and getting a simpler package of protocols that has more chance of success, I'll choose the latter, any day.
Life passes, but good protocols last forever. What I'd really love to see are AMQP networks where boxes can fail without consequence, where data routes around damage, where excess load is handled by throwing stuff away, and where the full capacity of the network can be delivered to applications rather than consumed by heavy messaging architectures.
My reasons for proposing this are partly that the current protocol workgroup is nearing burnout, and partly that I think the core architecture of AMQP has hit its limits and needs to be rethought. If my analysis is correct, all additions and refinements of the current core architecture are pure waste, and will probably work against, not for, AMQP's long term interests.
There is no way, in my view, to gently evolve today's specifications into working ones. We need to lock-down the good stuff actually running in production, park everything else, and start once again from first principles. This is what I'll aim to do in this article: Before general panic sets in, I'll say two things. Implementations can, and must, change with new knowledge.
This should be almost invisible to applications. It took us many attempts to build all the good, simple things in AMQP. Second, to those now yet familiar with the internals of AMQP, relax. The models I'll propose are simple. I'm aiming to make life easier for all of us, not harder.
My goal is to get the core AMQP specification down to a few pages. In AMQP, there is a primary elegant, powerful natural semantic: Just a quick recap for those not intimate with this semantic. A queue holds messages, it is a FIFO buffer. An exchange routes messages, it is an algorithm, with no storage. A binding is a relationship between an exchange and a queue, it tells the exchange what queues expect what messages.
Bindings are independent and orthogonal except that a queue will not get the same message more than once. There are two kinds of queue: AMQP defines a set of exchange types each corresponding to a specific routing algorithm, and lets applications create and use exchange instances at runtime.
In RabbitMQ, messages are sent over the channel to a named queue, which stores messages in a buffer, and from which consumers can receive and process messages. Queue declaration is an idempotent operation, so there is no harm in declaring it twice. This example demonstrates the basics of sending and receiving a message of one type.
RabbitMQ topic example This example is similar to the one earlier. To enable topic publishing, specify two additional properties: RabbitMQ uses the exchange and routing key properties for routing messaging. Look at how these properties change the code to publish a message. As before, you establish a connection to the RabbitMQ message broker, a channel for communication, and a queue to buffer messages for consumption. RabbitMQ uses these properties to route the message to the appropriate queue, from which a consumer receives the message using the same code from the first example.
This example should look familiar, as it follows the same flow to send and receive messages via a queue. Consumers should not use PooledConnectionFactory. For this example, use the master user name and password chosen when creating the Amazon MQ broker earlier. That is, only one thread can be actively consuming from a given logical topic subscriber. To solve this, ActiveMQ supports the concept of a virtual destination, which provides a logical topic subscription access to a physical queue for consumption without breaking JMS compliance.
To do so, ActiveMQ uses a simple convention for specifying the topic and queue names to configure message routing. MyTopic, as the publishing destination. ActiveMQ uses these names for the topic and queue to route messages accordingly.