We’re publishing messages to RabbitMQ but they hang in the outq instead of being processed by our handler.
.net core app running ServiceStack 6.*
Can someone cast their eyes over this and tell me where I’m going wrong?
Configure.Mq.cs
public class ConfigureMq : IHostingStartup
{
public void Configure(IWebHostBuilder builder) => builder
.ConfigureServices((context, services) =>
{
services.AddSingleton<IMessageService>(c =>
new RabbitMqServer(context.Configuration.GetConnectionString("RabbitMq") ?? "localhost:5672")
{
// DisablePublishingToOutq = true
}
);
})
.ConfigureAppHost(afterAppHostInit: appHost =>
{
var mqServer = appHost.Resolve<IMessageService>();
mqServer.RegisterHandler<UpdateSearchIndexMappingForActivityType>(appHost.ExecuteMessage);
mqServer.RegisterHandler<UpdateSearchIndexMappingResponse>(appHost.ExecuteMessage);
mqServer.Start();
});
}
MessageDTOs
[Route("/search/indexing/activityType", "POST")]
public class UpdateSearchIndexMappingForActivityType : IHasBearerToken, IPost, IReturn<UpdateSearchIndexMappingResponse>
{
public int Id { get; set; }
public int SystemId { get; set; }
public int From { get; set; }
public int To { get; set; }
public string BearerToken { get; set; }
public ResponseStatus ResponseStatus { get; set; }
}
public class UpdateSearchIndexMappingResponse
{
public ResponseStatus ResponseStatus { get; set; }
}
MessageHandler Service
public class LookupSearchIndexingServices : Service, IPost<UpdateSearchIndexMappingForActivityType>
{
public static ILog Log = LogManager.GetLogger(typeof(LookupSearchIndexingServices));
[Authenticate]
public object Post(UpdateSearchIndexMappingForActivityType request)
{
if (Log.IsDebugEnabled)
Log.Debug($"In LookupSearchIndexingServices: UpdateSearchIndexMappingForActivityType({request.Id})");
return new UpdateSearchIndexMappingResponse();
}
public void Post(UpdateSearchIndexMappingResponse request)
{
Log.Info("Search Index has successfully remapped");
}
}
Like I say, the message then just collect in the outq…
Here’s the Message Workflow, the .outq isn’t a queue that processes messages, it’s a topic other RabbitMQ clients can subscribe to, to get notified when messages are completed, i.e. it’s not part of the message workflow.
Ok, it looks like you don’t want them to be published to the .outq but want them published to the UpdateSearchIndexMappingResponse.inq so they are processed. Not sure why it’s not being published to the response .inq, perhaps the new profiling support we’ve added in v6.1.1 on MyGet will provide some insight at /admin-ui/profiling otherwise I’d recommend debugging the MessageHandler class to find out why it’s not being published to the Response.inq:
I’ve found that removing the [Authenticate] attribute from the MessageHandler fixes the problem but the BearerToken is being set correctly before the message is published and I can see the value on the messages sat in the Outq
Are you authenticating with JWT? Can’t authenticate otherwise.
Does the same SessionId from the authenticated user populating the MQ Request DTO make it to the Service? Does Request.GetSessionId() in MQ return the same Id?
If it’s returning the same id, can you retrieve the session manually from cache client with:
var sessionKey = SessionFeature.GetSessionKey(sessionId);
Request.GetCacheClient().Get<IAuthSession>(sessionKey)