gstackoverflow
gstackoverflow

Reputation: 37034

What should I be guided when I choose the protocol for RabbitMq

I try to dive into messaging in java. I am investigating RabbitMq and AMQP protocol. First of all I repeated several examples from https://spring.io/guides/gs/messaging-rabbitmq/ and examples from https://www.rabbitmq.com/

Now I want to learn it more detailed.

Official site feature section looks like advertisement. It says that RabbitMQ supports several protocols:

AMQP 0-9-1, 0-9 and 0-8, and extensions
STOMP
MQTT
AMQP 1.0
HTTP

But I can't understand why should I choose one of them.

Can you share your thoughts?

Upvotes: 2

Views: 995

Answers (3)

Peter
Peter

Reputation: 14108

This is an opinionated answer, but if you don't have a special use case (ie you're just going to let general services interact, like in a microservices architecture), just use AMQP 0-9-1. It's decent, and has good client library support in just about any programming language.

If you're working with IoT devices or otherwise constrained devices, use MQTT.

I see little need for STOMP and wouldn't recommend HTTP because it isn't considered reliable. Although they are text-based so could be useful to inspect messages. I believe RabbitMQ can translate messages so a publisher could send an AMQP message and a consumer could receive it in STOMP.

But again, my opinion.

Upvotes: 1

Lovisa Johansson
Lovisa Johansson

Reputation: 10518

The protocol only defines the communication between the client and the server and has no impact on a message itself. One protocol can be used when publishing and you can consume using another protocol.

AMQP (Advanced Message Queuing Protocol): RabbitMQ was originally developed to support AMQP which is the "core" protocol supported by the RabbitMQ broker. AMQP was designed to efficiently support a wide variety of messaging applications and communication patterns. Routing is a feature in AMQP, the process by which an exchange decides which queues to place your message on. Messages in RabbitMQ are routed from the exchange to the queue depending on exchange types and keys. (You got more complex routing options in AMQP compared to MQTT). RabbitMQ implements version 0-9-1 of the specification today - with legacy support for other versions. AMQP 1.0 is a radically different protocol from AMQP 0-9-1 / 0-9 / 0-8.

MQTT (Message Queue Telemetry Transport) with its minimal design makes it perfect for built-in systems, mobile phones and other memory and bandwidth sensitive applications. A specific task may as well be achieved using AMQP, but MQTT might be a more appropriate choice of protocol for this specific type of scenarios.

HTTP (Hypertext Transfer Protocol) is an application-level protocol for distributed, collaborative, hypermedia information systems. HTTP is not a messaging protocol. However, RabbitMQ can transmit messages over HTTP.

STOMP (Simple or Streaming Text Oriented Message Protocol), is a simple text-based protocol used for transmitting data across applications. It is much simpler and less complex protocol than AMQP, it is more similar to HTTP. STOMP clients can communicate with almost every available STOMP message broker, this provides easy and widespread messaging interoperability among many languages, platforms and brokers. It is, for example, possible to connect to a STOMP broker using a telnet client.

Source: https://www.rabbitmq.com/protocols.html and https://www.cloudamqp.com/docs/protocols.html

Upvotes: 2

Jesferman
Jesferman

Reputation: 1084

RabbitMQ is a way of exchanging data between processes, applications, and servers. As you say, you can choose one of the several protocols it support.

Your election will depend on which applications or systems you want to interconnect. For example:

  • MQTT: is a lightweight protocol with a low footprint ideal for communication between resource-constrained devices with low bandwidth, like embedded systems.
  • STOMP: is text-based, making it more analogous to HTTP and useful in messaging with web servers.

As you can see, each protocol has its advantages and drawbacks and your election will depend on which one adapts better to the application you want to build.

For a more detailed description of each protocol see this link

Upvotes: 2

Related Questions