RabbitMQ 4.x. Part one.

RabbitMQ 4.x. Part one.

RabbitMQ 4 was released in September 2024. The most important features are:

  • AMQP 1.0 becomes a core protocol
  • Khepri is now fully supported
  • Classic queue mirroring is removed


This post series will analyse this release's news and explain why you should update your old RabbitMQ.


Let's start with AMQP 1.0

You can find the AMQP 1.0 details in RabbitMQ here.


Practically speaking, here are two points that, as a developer, I found interesting:

  • More control during the message publishing with the Outcome State:

The publish function returns the Outcome.State for each single message:

PublishResult pr = await publisher.PublishAsync(new AmqpMessage("Subscribe to this newsletter");        

The Outcome State can be:

  • OutcomeState.Accepted: The message is accepted by the broker
  • OutcomeState.Released: The broker could not route the message anywhere
  • OutcomeState.Rejected: At least one queue rejected the message. Outcome.Error in case there is an error.

The feedback is immediate for each publish, giving you more control over what happens. 😱


  • More control during message consuming:

When you consume a message, the clients will provide you with four ways to deal with it

connection.ConsumerBuilder().Queue(queueName).MessageHandler((context, message) =>{        

  1. Accept(); Message accepted by the consumer. ( like the ACK)
  2. Discard(): The message cannot be processed. The broker can drop it or dead-letter it if it is configured.
  3. Requeue(); The message has not been processed, and the broker can requeue it


Ok, here are the interesting parts:


4. Discard(Dictionary<string, object> annotations): The message cannot be processed. You can discard it by adding annotations. In case of dead-letter the message will contain the annotation. I would only use AMQP 1.0 for this. 💥

5. Requeue(Dictionary<string, object> annotations): Requeue with annotations. The broker will deliver the message to the next consumer with annotations.🎶

Can you imagine the control you can have when something goes wrong? 🤯

(The example is in CSharp, but it is the same with other languages.)

AMQP 1.0 Clients

Oh yes, how can you start without clients?

The RabbitMQ team is writing a new set of AMQP 1.0 clients.

The clients are wrappers around existing and stable AMQP 1.0 clients ( like QPID, AzureAMQP, etc). They are designed to easily use all the features, be resilient with auto-reconnection, and support OAuth JWT authentication and token renewal.   

Here you can find the client's documentation

Conclusions

You may start using AMQP 1.0 on some part of your current environment. The team did a great job making all the protocols compatible. Thus, you can use AMQP 0.9.1, AMQP 1.0, the Stream protocol, etc., in the same environment.

AMQP 1.0 is much more than this. In this post, I invite you to explore and try the protocol. You may use it instead of AMQP 0.9.1.


Here you can find more documentation about AMQP 1.0:


Need help? Check https://www.rabbitmq.com/contact#consulting for community and commercial support.


Happy RabbitMQ messaging! 🎉

RabbitMQ is not an actual rabbit i heard

Emiliano Pisu

🎥 Sensei & Co-Host @ DevDojo IT 🎤 Speaker ♿️ Accessibility WCAG Expert ✨ Turning Designs into interactive things 🦸♂️ Your friendly neighborhood Design Engineer

4mo

Gabriele Santomaggio ad ogni episodio mi viene sempre più voglia di entrare nella tana del GiallConiglio <3

To view or add a comment, sign in

Others also viewed

Explore topics