MQ Server Queue Prefix Usage

We have a system that will have one ServiceStack BasicAppHost that runs an MQ client / host per state (Louisiana, Texas, Mississippi).

This MQ client will pass messages back and forth between various state systems (NCIC, Criminal History, DMV, etc…) and our main Web API.

The server side is working great - I’m able to deploy and start the host, and based on my settings.json, I can:

var mqConfig = AppSettings.Get(“Mq”);

QueueNames.SetQueuePrefix(mqConfig.StateQueuePrefix); (LA for example)

Now this host only listens for messages for Louisiana.

On the UI + Web API side of things is where I get a little confused. All users (from many states) will utilize a React Dashboard with a standard SS web api. I have the State the user is tied to, but how do I queue a message specifically for LA versus say TX?

EDIT:

I see the helpers QueueNames.cs and QueueNames<T>.cs.

QueueNames.ResolveQueueName almost gets me there, except it doesn’t let me specify the Queue Prefix that I need for that user.

Note: the QueueNames defines global static configuration for the App which isn’t threadsafe to change at runtime.

I’m not sure I understand where the issue is, the IMessageQueueClient lets you send to any arbitrary queue name so are you just asking how to construct a queue with a custom prefix?

The implementation for QueueNames.ResolveQueueName() is just:

public static string ResolveQueueName(string typeName, string queueSuffix)
{
    return QueuePrefix + MqPrefix + typeName + queueSuffix;
}

So if you want to create a queue with a custom prefix? you can just do:

var customQ = myPrefix + QueueNames.MqPrefix + typeName + queueSuffix;

Yeah I was just asking if there was a safe, SS way to construct the queue name safely, as there is on the server side.

On the server side I can use set queue prefix. On the message producer side it looks like I’ll just have to append the state abbreviation to the front.

Thanks

1 Like