I'm creating a solution which uses the new .NET Aspire orchestrator support. I would (obviously) love to be able to use the Aspire components for RabbitMQ and Redis along with the ServiceStack support for the same technologies (see here and here) - but I am struggling to get the RabbitMQ component to play nicely with the ServiceStack RabbitMQ implementation.
In theory, it sounds like this should be achievable - both rely on the RabbitMQ .NET client, and I can inject a wired-up RabbitMQ ConnectionFactory into a ServiceStack RabbitMqConnectionFactory instance when setting up the MQ Server:
public class ConfigureMq : IHostingStartup
{
public void Configure(IWebHostBuilder builder) => builder
.ConfigureServices((context, services) =>
{
services.AddSingleton<IMessageService>(c =>
new RabbitMqServer(new RabbitMqMessageFactory(c.GetRequiredService<IConnectionFactory>() as ConnectionFactory)));
})
.ConfigureAppHost(afterAppHostInit: appHost =>
{
var msgService = appHost.Resolve<IMessageService>();
msgService.RegisterHandler<MqExecutePing>(appHost.ServiceController.ExecuteMessage);
appHost.Resolve<IMessageService>().Start();
});
}
unfortunately, this seems to throw the following error when trying to publish a message :
System.MissingMethodException: Method not found: 'Void RabbitMQ.Client.IModelExensions.BasicPublish(RabbitMQ.Client.IModel, System.String, System.String, RabbitMQ.Client.IBasicProperties, Byte[])'.
at ServiceStack.RabbitMq.RabbitMqProducer.PublishMessage(String exchange, String routingKey, IBasicProperties basicProperties, Byte[] body)
at ServiceStack.RabbitMq.RabbitMqProducer.Publish(String queueName, IMessage message, String exchange) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack.RabbitMq/RabbitMqProducer.cs:line 117
at ServiceStack.RabbitMq.RabbitMqProducer.Publish(String queueName, IMessage message) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack.RabbitMq/RabbitMqProducer.cs:line 76
at ServiceStack.RabbitMq.RabbitMqProducer.Publish[T](T messageBody) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack.RabbitMq/RabbitMqProducer.cs:line 61
at ServiceStack.RabbitMq.RabbitMqProducer.Publish[T](T messageBody) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack.RabbitMq/RabbitMqProducer.cs:line 65
at Redacted.Api.Accounts.ServiceInterface.HealthServices.Any(MqPing request) in D:\repos\Redacted\src\Redacted.Api.Accounts\ServiceInterface\HealthServices.cs:line 16
at lambda_method2(Closure, Object, Object)
at ServiceStack.Host.ServiceRunner`1.ExecuteAsync(IRequest req, Object instance, TRequest requestDto) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Host/ServiceRunner.cs:line 131
Could this be because of version differences between the underlying RabbitMQ .NET client? Is there a way around this?