.NET - Enforcing Queue to Respect Message Priority

Options
andrzejk
andrzejk Member Posts: 6
edited October 2023 in Connectors & Integrations #1
Hello everyone,

I am trying to implement a simple PoC solution to check whether Solace PubSub+ will be appropriate for my company.
All went fine to the moment I wanted to use priority messaging.
I would like to
1. create a queue from .NET
2. assign Priority to messages
3. enforce the queue to respect message priority

Points 1 and 2 were simple enough, partially covered by examples provided by Solace.
BUT - nowhere it is mentioned how to cover the last 3rd point.
All that documentation says is this - https://docs.solace.com/Messaging/Guaranteed-Msg/Configuring-Queues.htm#Enforcing-Priority.

All I have found is doing that from the CLI
`solace(configure/message-spool/queue)# respect-message-priority`
or in the Cloud UI interface (on the Queue level there is a toggle to respect the priority or not).
I have tried checking properties of the Session, Flow and Queue and none of them has 'RespectMessagePriority' -like property :(

Does anyone know if this is possible?

Best Answer

  • amackenzie
    amackenzie Member, Employee Posts: 260 Solace Employee
    edited October 2023 #2 Answer ✓
    Options

    You cannot create queue templates from the messaging api. They must be created by a management user and if that must be done programmatically, you would need to use SEMP.

    This is the model across all of the APIs. The messaging APIs, such as the .Net API you are using, do not have admin/management capabilities beyond the creation of queues. And that is on purpose.

    In Solace broker, management users and messaging usernames are different and they do different things.

    I would suggest creating the queue template using the Broker Manager UI, which is a 1 time thing and can be reused over and over by your .Net app.

    If you absolutely must do ALL of this via code, look at the SEMP API, which is REST-based and could provision the queue itself or create a queue template your messaging app could use. You need to auth using a management user, though, not the current client username .

Answers

  • amackenzie
    amackenzie Member, Employee Posts: 260 Solace Employee
    Options

    Hello,

    Respect Message Priority is available to be set via Queue Templates (as well as other non-default settings). I would recommend you create your queue to use a queue template that has that setting in place in the template.

    https://docs.solace.com/Messaging/Guaranteed-Msg/Configuring-Endpoint-Templates.htm

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 921 admin
    edited October 2023 #4
    Options

    Hi @andrzejk,

    Are you just trying to take the feature for a spin to see how it works?

    If so you can do it as follows:

    1. Create queue which enforces message priority
    2. Publish messages to the queue with different priorities
    3. Have a consumer bind to the queue and see the messages show up in priority order

    You can even do it pretty easily using the Try-Me that you mentioned ;)

    See the image here where my priority 9 message was actually send last, but received first.

    Hope that helps!

  • amackenzie
    amackenzie Member, Employee Posts: 260 Solace Employee
    Options

    Thanks for that clarification, @marc . To be clear, my response was assuming you have to create the queue via the .Net API.

    Marc's answer correctly points out that there are easier ways (CLI, SEMPv2, Broker Manager web UI), that allows you to create the queue with the proper settings for your App before you use it in your .Net app.

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 921 admin
    edited October 2023 #6
    Options

    Haha. I didn't even see you beat me to the answer @amackenzie 🤣

    But yes, combining what we both said should give all the info necessary 😜

  • andrzejk
    andrzejk Member Posts: 6
    edited October 2023 #7
    Options
    updated comment below :)
  • andrzejk
    andrzejk Member Posts: 6
    edited October 2023 #8
    Options

    Thanks @amackenzie and @marc! Thanks for posting these.
    What I want to do, is to do all of that via .Net.
    I.e. I want to create a queue and make it respect message priorities. All from .Net.

    I need to create them dynamically so doing anything from Solace CLI doesn't fit this.
    Also, I see no way of creating Queue Templates in .Net :/

    Do you know if such feature is available in .Net nuget SolaceSystems.SolClient.Messaging package ?
    Example from

    doesn't hint how to do that (attached) :) It just creates and provisions a queue. Where is its configuration? EndpointProps doesn't provide all the configuration options available for the Queue.

    Maybe it's just not available using the nuget package but it is possible using SEMP API? It would be fine if I could call the appropriate API in order to configure the queue.

  • amackenzie
    amackenzie Member, Employee Posts: 260 Solace Employee
    edited October 2023 #9 Answer ✓
    Options

    You cannot create queue templates from the messaging api. They must be created by a management user and if that must be done programmatically, you would need to use SEMP.

    This is the model across all of the APIs. The messaging APIs, such as the .Net API you are using, do not have admin/management capabilities beyond the creation of queues. And that is on purpose.

    In Solace broker, management users and messaging usernames are different and they do different things.

    I would suggest creating the queue template using the Broker Manager UI, which is a 1 time thing and can be reused over and over by your .Net app.

    If you absolutely must do ALL of this via code, look at the SEMP API, which is REST-based and could provision the queue itself or create a queue template your messaging app could use. You need to auth using a management user, though, not the current client username .

  • andrzejk
    andrzejk Member Posts: 6
    Options

    Thanks @amackenzie. That's exactly what I was looking for.

    Creating and using a queue template in Broker Manager UI is quite nice and works as expected. Still, I am afraid my project requires everything being done on the fly. This might change some day but current architecture requires that.

    I will have another look at the SEMP API and try to create a queue with the config already there. Or, if API doesn't allow providing the RespectMessagePriority attribute while creating the queue, I will create a template first.

    Much appreciate your help!