I’m running a BasicAppHost because I don’t need any HTTP (only MQ messaging). This service is a windows service that is deployed to various state agencies and acts as a middle man between my normal SS Web API and other state services.
All works great with RabbitMq in development. I can startup a rabbit mq docker instance, setup the config on my Web and BasicAppHost, and “pass” messages from the Web to the BasicAppHost. The Web only acts as a producer for now.
But as soon as I setup the deploy pipeline to AWS, replacing RabbitMqServer with SqsMqServer - nothing fires. I see the Queues created in my AWS console (so I know the BasicAppHost is registering handlers properly), but can’t get messages to fire in my Beta AWS environment, nor on localhost debug mode.
The AWS SQS queues show no messages have ever been received.
Relevant code
Web API Startup
var sqsAccessKey = AppSettings.GetString("SQS:AccessKey");
var sqsSecretKey = AppSettings.GetString("SQS:SecretKey");
container.Register<IMessageService>(c => new SqsMqServer(sqsAccessKey, sqsSecretKey, RegionEndpoint.USGovCloudWest1));
Web API Producer Usage
var envName = AppSettings.GetNullableString("Environment:Name");
var queueName = string.IsNullOrWhiteSpace(envName) || envName == "Local"
? sessionUser.QueueName<StateHostRequest>()
: $"{envName}.{sessionUser.QueueName<StateHostRequest>()}";
if (envName != "Local")
queueName = queueName.ToValidQueueName();
// Simplified, this comes out to: Beta-LA-mq-StateHostRequest-inq which matches what is in SQS
using (var mqClient = ResolveService<IMessageService>().CreateMessageQueueClient())
{
var stateHostRequest = new StateHostRequest()
{
//...
};
mqClient.Publish(queueName, new Message<StateHostRequest>(stateHostRequest));
}
Windows Service Self Host Setup (State Host)
Each state has it’s own host, so we register it with a prefix of [EnvironmentName].[StateAbbreviation].
var sqsStatePrefix = AppSettings.GetString("SQS:StateQueuePrefix");
var sqsEnvironmentName = AppSettings.GetString("Environment:Name");
var sqsAccessKey = AppSettings.GetString("SQS:AccessKey");
var sqsSecretKey = AppSettings.GetString("SQS:SecretKey");
QueueNames.SetQueuePrefix($"{sqsEnvironmentName}.{sqsStatePrefix}");
container.Register<IMessageService>(c => new SqsMqServer(sqsAccessKey, sqsSecretKey, RegionEndpoint.USGovCloudWest1)
{
DisableBuffering = true
});
var mqServer = container.Resolve<IMessageService>();
mqServer.RegisterHandler<StateHostRequest>(this.ExecuteMessage);
mqServer.RegisterHandler<StateHostResponse>(this.ExecuteMessage);
mqServer.Start();
I’ve also tried changing BasicAppHost to AppHostBase, and calling mqServer.Start() in my SS Web API (although I don’t believe I need it to simply produce messages, at least, I never did with RabbitMqServer).
How do messages get from AWS SQS to my mqServer? Is it a poll? Does my service need to be on some public IP address? Does it use HTTP?