-1

In the Solace Java API, I can create a persistent messaging queue using

MessagingService.createPersistentMessageReceiverBuilder()

The above takes a Queue.durableNonExclusiveQueue() or Queue.nonDurableNonExclusiveQueue(), with similar methods for an exclusive queue as well.

There's a MessagingService.createDirectMessageReceiverBuilder(), but it effectively only takes Topics via the .withSubscriptions(). I didn't see a way to create a direct queue.

I'm confused on the definitions Solace uses:

  • Direct means the destination topic does not have to be listening at the time. It does not hold the messages until something can process it. I don't know why they didn't call it non-persistent.
  • Given there's a "persistent" word being used, I don't then know what "Durable" means. I would have thought it would mean that somehow Solace preserves the messages so that if Solace goes down, all the messages are written to disk and not just in volatile memory. Again, what's the difference between Durable and Persistent?
  • Did they not have a direct queue thinking it would be hard to make usable by the receiving party? I'm sure there's some big reason it's not there based on my understanding.
  • In PubSub+, I think messages can be pushed with a simple topic added to it. Is that peristent? Is that durable?

These are questions I had after reading @tamimi-ahmad's answer. Due to length, I'm putting them here:

  • "Think of queues on the Solace broker as nothing but another client that is subscribing to topics. Which means that you can add topic subscriptions to queues that attracts the messages you want, and any client that is bound to the queue will consume the messages in it."

    Let's say I wanted to put data in Solace. Let's call it a Message. I want to get it from the content creator to whoever cares to listen. At no time, does the API allow me to specify the Queue that it lands on, yet it's possible to see messages "queued" on the queue. In Solace, is a queue really just messages that got sent to a certain topic (or multiple topics via wildcard)? In otherwords, you'd never directly send to a queue?

  • Perhaps this is moot, but why can't you create a NON_DURABLE, NON_EXCLUSIVE Queue?

  • Solace allows a persistent message receiver via messagingService.createPersistentMessageReceiverBuilder(). Why can't you do messagingService.createDirectMessageReceiverBuilder()? Can you not receive direct messages?

  • I still don't understand the difference between Persistent and Durable. I'm guessing Persistent is used for messages published, yet durable is for when they get matched to a topic subscription and are saved for later consumption.

  • Using the API, I can create a named persistent receiver using

receiver = messagingService.createPersistentMessageReceiverBuilder().build(queue);

Why can't I name a DirectMessageReceiver?

  • What is the best way to cache a MessageReceiver and a MessagePublisher in Spring Boot?
  • I read the article on message promotion. One thing it said to do was avoid message promotion due to unwanted "backpressure" saving on an endpoint. I think backpressure essentially is the time and WIP cost due to saving a message. I gather it's somehow worse to save that message at the time it gets matched to a queue than when it was first published. Is that right?
Woodsman
  • 901
  • 21
  • 61

1 Answers1

1

Before tackling this question, let's take a step back and cover some best practices, terminologies, and basic concepts when using Solace PubSub+ Event Broker.

From a Publisher perspective (MessagePublisherBuilder)

The recommended best practice is to publish messages on topics. Think of topics as "labels" that events are sent on. Topics are used by the Solace PubSub+ Event Broker to decide which subscribers to route the event to. Topics are not endpoints, meaning that you do not create topics on the broker before sending a message. Topics are very dynamic which means you can send messages on as many topics as you'd like (!) and the broker will mange the list of topic subscriptions. Since topics are not endpoints, think of them as metadata describing what you are publishing.

The best practice is to always publish messages on topics regardless what Message Exchange Pattern (MEP) you want to use: Direct vs. Guaranteed. If you are using a Guaranteed MEP in your application, then publish the message on a topic with a persistent flag set to true.

Using the Solace PubSub+ Messaging API for Java:

  • Publishing Direct messages: DirectMessagePublisher publisher = messagingService.createDirectMessagePublisherBuilder()

  • Publishing Guaranteed messages: PersistentMessagePublisher publisher = messagingService.createPersistentMessagePublisherBuilder().

Note that the persistent flag is automatically set when using the new Solace PubSub+ Messaging API.

From a Consumer perspective (MessageReceiverBuilder)

Depending on your use-case, you have two options:

  1. I want the highest/fastest performance possible and it's okay to loose messages --> Direct MEP
  2. I want to persist all messages. Theres two variations of this: persist messages when client is offline or only when client is connected --> Guaranteed MEP

For the first use-case, you will be using the MessagingService.createDirectMessageReceiverBuilder() that only takes subscriptions. Ultimately, you dont need any queueing mechanism since you only want to attract messages that are sent on a topic that matches the subscription needed. Read more about Solace Wildcards

For the second use-case, this is where queues come to the rescue! A client BINDS to a queue on the Solace Pubsub+ Event Broker and consumes the messages on it. Hence, the MessagingService.createPersistentMessageReceiverBuilder() method takes a queue as a parameter. Note below the different types of queues.

Think of queues on the Solace broker as nothing but another client that is subscribing to topics. Which means that you can add topic subscriptions to queues that attracts the messages you want, and any client that is bound to the queue will consume the messages in it.

Note on message promotion

If a Publisher publishes messages without setting the persistent flag on the message (i.e uses Direct MEP), what happens if a queue subscribes to the topic the message is sent on? Meet message promotion. Here is a blog post about understanding solace delivery modes that will be helpful - Understanding Solace Delivery Modes: Promotion & Demotion

Note on Durability and Exclusivity

  • Durable queue: exist on the broker even if no client is bound to it. I.E. persist messages even when client is offline. Durable endpoints have life spans independent of any particular Session. Created on the broker by an admin using the GUI, management API (SEMP), or CLI. Can also be created by a client using a Messaging API.

  • Non-durable queue: Temporary queues and only created by the client and lasts for the duration of the Session. When the session is closed, the queue and the messages in it will be deleted after 60 seconds.

  • Exclusive queue: only one client can bind to a queue. This guarantees ordering. If other clients bind to the same queue then they are in standby mode; i.e. only when the first clients disconnects from the queue then the second (third, fourth.. and so on) will receive the messages.

  • Non-exclusive queue: All clients bound to the queue will receive messages in a round-robin fashion

Hope this helps! Feel free to check out the Solace Community forum as well as there are alot of good resources from community members there. And you are encouraged to share your journey and findings there as well

Resources

Tamimi Ahmad
  • 111
  • 5
  • Thanks for your thorough and thoughtful reply. I think that helped, but I had follow up questions. I'm adding my additional questions to the end of the original post. – Woodsman Nov 27 '22 at 22:30