Configuring and using SS with SQS issues

I’ve been tasked with getting SS to work with AWS/SQS replacing our existing RabbitMq implementation that was not using SS at all. Our existing model with Rabbit is a fire and forget style system and several different microsystems subscribe to similar types for which MassTransit creates exchanges in Rabbit.

I’ve been able to get the basics running in SS using the examples online but I have a few questions/challenges.

  • All of the queues and messages posted from SS are invisible to me in the console. I know they exist because I can query the list of queues and see them in the debugger but from the console nothing. I’m logged into the console as myself and in code I’m using my own AWS keys so I don’t know whats up with that.

  • How would I duplicate the idea of several micro services (each running SS for example) all having a queue of their own for the application and then subscriptions to each type. When one microsystem (MS) broadcasts a general message of type X I want all of the other microservices to pick it up and call its own endpoint (if they’ve registered that type of course). I think we’ll need to use SNS topics which brings me to the next question:

  • How can we publish a message to a topic?

I’m having trouble figuring out how all of the classes fit together for Sqs. For example:

        var mqServer = new SqsMqServer(accessKey, secretKey, RegionEndpoint.USWest1);
        var mqClient = _mqService.CreateMessageQueueClient();

        var message = new Message<CustomerDemographics>(new CustomerDemographics { SomeValue = "created in HelloWorld endpoint"});

        var tempQueueName = mqClient.GetTempQueueName();
        var msgFactory = _mqService.MessageFactory as SqsMqMessageFactory;
        var msgProducer = msgFactory.CreateMessageProducer() as SqsMqMessageProducer;
        var queueManager = msgFactory.QueueManager;
        var sqsClient = queueManager.SqsClient;
        var queues = sqsClient.ListQueues(new ListQueuesRequest());
        var sqsDemoQueue = queueManager.GetQueueDefinition("SOME-QUEUE-I-CREATED-IN-AWS-CONSOLE");
        var sqsCustomerDemographicInq = queueManager.GetQueueDefinition(qCustDemoAllQueueNames[0]);
  • How does the temporary queue name fit into all of this?

  • It seems SS creates four queues for each type like this:

[0] = {string} “mq:CustomerDemographics.inq”
[1] = {string} “mq:CustomerDemographics.priorityq”
[2] = {string} “mq:CustomerDemographics.outq”
[3] = {string} “mq:CustomerDemographics.dlq”

How do these queues operate together?

Any thoughts, ideas or general guidance is welcome.

Thank you,

-Matthew Mackay

The MQ Support in ServiceStack is a simple Request/Reply Queue as explained in the Message Workflow where normal messages are sent in the .inq but you can optionally send different messages to the .priorityq to have a different queue for messages you want to execute immediately by skipping the normal MQ. That’s what the MQ support in ServiceStack is designed around - which is effectively a different reliable endpoint for invoking ServiceStack Services.

If you want to broadcast messages that would need to be done outside of ServiceStack’s existing MQ Topics/Queue’s as they’re for the different Request/Reply use-case which ServiceStack’s MQ Support is built around.

For publishing a message to a topic that would need to be done outside of ServiceStack, you can use queueManager.SqsClient but you’d be publishing and subscribing to a topic outside of ServiceStack.

1 Like

Thanks for responding I really appreciate it and let me say that we love SS!

So, normal publishing of a type T is sent to a queue named “mq:[T’s name].inq”

  • How do I publish to priorityq and does it call the same end point? I don’t see overloads on mqClient.Publish

  • What are the temporary queues being used for?

  • What if several different microservices are subscribing to the same queue by type “mq:CustomerDemographics.inq” ? Could/should I change the MqPrefix so that each application has a unique queue name for CustomerDemographics in our example?

Thanks again for your help!

-Matt

You need to set the IMessage.Priority to >= 1, e.g:

var message = new Message<CustomerDemographics>(new CustomerDemographics {  ... }) {
    Priority = 1
};

What are the temporary queues being used for?

Not sure which temporary queues you’re referring to, but temporarily queues are useful in MQ Request/Reply patterns.

The idea is that it shouldn’t matter who processes messages off the queue, they’d just be processed by the first available consumer and adding more consumers should just mean that messages are getting processed faster - this is how MQ’s achieve natural load-balancing.

1 Like