In a previous blog post I explained the two delivery modes that Solace supports: direct messaging and persistent messaging, which is also called guaranteed messaging. In this blog post I will explain the promotion and demotion of messages.
Before diving in to message promotion and demotion, it’s important to understand the basics of publish/subscribe messaging. In short, it’s a message exchange pattern that lets applications send (publish) information (as messages) to a topic (a message property represented by a text string) that indicates what the message is about, and applications that want that kind of information can subscribe to receive all messages with topics that indicate information they want to receive. This makes it easy and efficient to fan messages out to any number of interested applications without any configuration or overhead.
Another thing you need to understand before we dive in to message promotion and demotion is that topics can be mapped to queues. A topic subscription (i.e. that is, the means by which applications express interest in a given topic) can be applied to a queue. A queue is an object on the Solace PubSub+ Event Broker that stores messages (hence the term “persistent”) for an application to receive later. Applying a topic subscription to a queue means messages matching that subscription will be received and buffered by the queue.
Message promotion occurs when a message that was published as direct ends up on an endpoint, which effectively guarantees its delivery. A direct message can end up on an endpoint when the endpoint’s topic subscription matches the message’s topic. In the below example, we can see the direct message is published to topic “a/b/c”. The queue subscription is “a/b/>”, which matches the published topic. The message is still received by the direct subscriber because of the subscription “a/b/c” and is also saved in the queue.
It is important to note that the message saved onto the queue has a change in delivery mode. Because the message was published as direct but is now saved in a queue making it act as a guaranteed or persistent message, the event broker changes the delivery mode to Solace ‘non-persistent’ to indicate to the consuming application that the message was promoted.
Message demotion, on the other hand, occurs when a message published as persistent matches a direct topic subscription. In this case the message delivery mode is changed from ‘persistent’ to ‘direct’ for the direct subscriber, but the message is still acknowledged to the publishing application once it has been saved in the receiving endpoint(s).
It’s important to know that direct messages, even when promoted, are never acknowledged to the initial publisher. When a higher quality of service is required, you should always publish messages as persistent.
You need to be wary of message promotion, because it can put unwanted backpressure on saving messages to an endpoint. Message promotion should be avoided whenever possible by ensuring that endpoint subscriptions do not match published direct messages.
I hope I’ve helped you understand the concept of message promotion and demotion. If you found this post useful, visit this section of our docs, and our PubSub+ for Developers page for more information. If you have any questions about message promotion and demotion, our developer community is a great place to pose questions and see what your fellow developers are talking about.
I have worked at Solace as a Customer Support Engineer, and as a Global Training Professional. I help customers to migrate from a siloed, monolithic architecture to an Event Driven Architecture. Solace PubSub+ enables the movement of data in an asynchronous manner, allowing distributed applications to seamlessly connect over any protocol.[position] => [url] => https://solace.com/blog/author/leahrobert/ ) )