开发者

Switching from ActiveMQ to RabbitMQ

I'm currently using ActiveMQ for my messaging needs; aside from a few db failures, it has worked well. However, I'm at the very least considering trying out RabbitMQ. But before I do, I'd like to understand the following:

  1. In what ways does RabbitMQ differ from ActiveMQ? What does RabbitMQ do better or worse than ActiveMQ?
  2. Comparatively, how easy/difficult is RabbitMQ to configure?
  3. How well integrated is RabbitMQ 开发者_开发百科with Spring?
    • With ActiveMQ, I simply wire a connection factory bean into a JmsTemplate and I use DefaultMessageListener beans to connect queues to their respective handlers. Can I essentially do the same with RabbitMQ?


  1. RabbitMQ is an AMQP broker, while ActiveMQ is a JMS one. I suggest you read the AMQP wikipedia article to get an idea of the concepts used in AMQP, which are different than the ones you're familiar in JMS. One of the main difference is that in AMQP a producer sends to an exchange without knowing the actual message distribution strategy while in JMS the producer targets either a queue or a topic (thus being aware of the type of message routing in place). So it's hard to tell what's done better or worse, as the semantics are very different between JMS and AMQP.

  2. RabbitMQ's queues and exchanges are all configured via the AMQP protocol so a client library allows you to configure all your destinations and their behavior. ActiveMQ requires specific destination configuration because the JMS spec doesn't cover any of the administration side of things. Besides that, RabbitMQ's system configuration is Erlang-esque, while ActiveMQ is usually configured in XML. So you'll have to get used to the {tuple} and <> lovely syntax. RabbitMQ is usually installed with OS packages, while ActiveMQ distributions are archives you drop anywhere (or Maven deps you embed into something else).

  3. Very well :) See Spring AMQP.


AMQP is an application-level standard for Message Oriented Middleware (MOM). JMS is a standard API for Java for communicating with MOM.

Two different Java applications using JMS could be using different MOM and hence still be unable to communicate. ActiveMQ is a MOM system with a JMS library that allows Java programs to access it using JMS, but it can't necessarily communicate with another JMS Java program using, say, WebLogic MOM.

Different AMQP MOM systems can interoperate with each other (assuming that they are using the same version of AMQP) since AMQP is a standard along the same lines as, say SMTP. There is no reason that an AMQP MOM system could not also provide a JMS library for its Java clients. SwiftMQ, for example, provides a JMS API and uses AMQP 1.0.

Unfortunately not all AMQP systems (and there are many) are using version 1.0 of AMQP yet. RabbitMQ (at the time of this writing) does not yet provide AMQP 1.0 support. Some of the other AMQP systems are Apache QPID and StormMQ, but there are many others. Once all of these are supporting AMQP 1.0, then they should all be inter-operable with each other.

On their site at http://activemq.apache.org/amqp.html, ActiveMQ says, "We expect ActiveMQ to implement the latest version, once it is finalized. But, at this time, ActiveMQ does not implement AMQP." Now that AMQP 1.0 is out, there is no further word from ActiveMQ about when they will support it.


Since RabbitMQ is an AMQP broker where the configuration is largely handled through AMQP itself, most of your questions don't make any sense.

One tricky problem with RabbitMQ is that many OS packages are at 1.72 which is woefully out of date. You would do far better to get a .deb or .rpm package of RabbitMQ 2.51 direct from their site. After that the only config you really need to do outside of AMQP, is to create vhosts and user permissions using rabbitmqctl. Or, you could download the .ez plugins for the web management console and place them in the correct directory before restarting RabbitMQ. This web management console is highly recommended if you are using 2.51 but impossible if you are stuck with the default 1.72 that Debian and Ubuntu saddle you with.

Once you have RabbitMQ running, you can use any language and any AMQP library. I've personally taken over a Python system using pika, amqplib and kombu. Now I'm using haigha and the Java library from Scala, all talking to each other over AMQP (and the MQ broker of course).


Comparing JMS/AMQP concepts to compare ActiveMQ and RabbitMQ is not the most important: ActiveMQ speaks AMQP, and there is JMS client for RabbitMQ in the commercial edition (was called vFabric RabbitMQ). Yet some AMQP concepts (routing keys) might be useful in some use cases.

I have used both and like both:

  • Found Erlang+RabbitMQ harder to install on some systems (outdated package repositories) than Java+ActiveMQ
  • RabbitMQ has some nice clustering/HA options (mirrored queues, cluster federation). There is no need for a shared ZooKeeper or a shared database, but one should take care of the "split brain" problem.
  • ActiveMQ is heavier (memory consumption)
  • ActiveMQ is perfectly integrated with Apache Camel, with RabbitMQ you'd better use Spring Integration (Camel RabbitMQ/AMQP is bit rough)
  • ActiveMQ supports XA transactions, can be embedded in Java applications, can embedded Camel.
  • Java automated testing with ActiveMQ is easier (embedded broker)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜