We will look into Spring AMQP today.

Spring AMQP

Spring AMQP is the Spring implementation of AMQP-based messaging solutions. Spring AMQP provides us a “template” as a high-level abstraction for sending and receiving messages. We will look into following topics in this spring AMQP. tutorial.

  1. What is AMQP?
  2. Why we need AMQP?
  3. Difference between JMS and AMQP
  4. How Spring AMQP works?
  5. Spring AMQP Modules

What is AMQP?

We have already discussed some JMS concepts and examples in my previous posts. In this post, we are going to discuss AMQP protocol and Spring AMQP Messaging.

AMQP stands for Advanced Message Queuing Protocol. AMQP is an open standard protocol for implementing MOMs (Message Oriented Middleware).

Why we need AMQP?

We have JMS API to develop Enterprise Messaging systems but why we need another Messaging standard.

The main drawback or limitation of JMS API is interoperability that means we can develop Messaging systems that will work only in Java-based applications. It does not support other languages.

AMQP solves the JMS API problem. The major advantage of AMQP is that it supports interoperability between heterogeneous platforms and messaging brokers. We can develop our Messaging systems in any language (Java, C++, C#, Ruby etc.) and in any operating system; still, they can communicate with each other by using AMQP based message brokers.

Difference between JMS and AMQP

In this section, we will discuss about what are the differences between JMS and AMQP protocols.

    1. Interoperability

JMS Application works in any OS environment, but it supports only Java platform. If we want to develop the below system architecture by using JMS API then all those systems should be developed by using Java language only.

But if we use AMQP standard to develop the same system, then we can develop those systems in any language that means System-1(JAVA), System-2(C#), System-3(Ruby) and System-4(C++).


JMS API is specific for Java Platform only, but AMQP supports many technologies.

    1. Messaging Models

As we have already discussed, JMS API supports two kinds of messaging models: P2P(Peer-to-Peer) Model and PUB/SUB (Publisher/Subscriber) Model.

AMQP supports five different Messaging models (or Exchange types)

      1. Direct Exchange
      2. Fanout Exchange
      3. Topic Exchange
      4. Headers Exchange
      5. System Exchange
    1. Message Structure

JMS Message is divided into 3 parts: Header, Properties, and Body.
AMQP Message is divided into 4 parts: Header, Properties, Body, and Footer.

    1. Message Types

JMS API supports 5 types of messages as part of the Body section, but AMQP supports only one type of message – Binary (bytes) message.

How Spring AMQP works?

Spring Framework provides Spring AMQP API to integrate AMQP Message brokers with Spring applications to develop Enterprise Messaging Systems.

In AMQP Messaging systems, Message Publisher sends messages to Exchange. Publisher does not know which queue is configured to this Exchange and which Consumer is associated with this Queue.

While configuring Exchange, we will map it to one or more Queues by specifying some routing key.

AMQP Consumer is connected to Queue and listening to messages with some routing key.

When Publisher sends a message into Exchange, then Exchange uses this routing key and send those messages to associated Queue. When the Queue receives messages, then associated Consumer receives those messages automatically.


For example, we have implemented our AMQP Messaging system by following above architecture.

If Publisher sends a message with Route key = 1, then this message is routed to Queue1, then to Consumer1.

If Publisher sends a message with Route key = 2, then this message is routed to Queue2, then to Consumer2.

NOTE: Most popular AMQP protocol implemented Message brokers or JMS Servers are:

  1. Apache Active MQ server
  2. Spring Rabbit MQ server

Spring AMQP Modules

Spring Framework provides two set of APIs to deal with AMQP protocol servers. Spring AMQP Projects are located at the following website:


    1. Spring RabbitMQ AMQP API

Spring RabbitMQ AMQP API is used to implement messaging applications with Spring Rabbit MQ server. This API is developed in two Spring modules:

    • spring-amqp:

It is base abstraction for AMQP Protocol implementation.

    • spring-rabbit:

It is the RabbitMQ implementation.

  • Spring ActiveMQ AMQP API

This API is used to implement messaging applications with Apache Active MQ server. This API uses Spring AMQP abstraction module with ActiveMQ API:

    • spring-amqp:

It is base abstraction for AMQP Protocol implementation.

    • activemq-spring:

It is the ActiveMQ implementation.


  • Both Spring AMQP and Spring RabbitMQ Modules are from Pivotal Team (Spring Framework). RabbitMQ servers is also from Pivotal Team.
  • ActiveMQ Server is from Apache Software Foundation. Apache ActiveMQ has released an API to support Spring Framework that is activemq-spring (It’s not from Pivotal Team).

That’s it all about Spring AMQP Messaging.

Further Reading: Spring RabbitMQ, Apache ActiveMQ

By admin

Leave a Reply

%d bloggers like this: