Reputation: 403
I need to integrate MQ feature in my ServiceStack application. I have registered the Message Handler in AppHost. The handler for my ServiceStack request(Post) will publish the message to the MQ broker. I have created the consumer for that message. This is all working fine.
Now what I need is to have multiple threads available to consume the message and process that. I have read that ServiceStack implementation of rabbitMQ provides the feature to specify multiple threads for an operation: https://github.com/ServiceStack/ServiceStack/wiki/Rabbit-MQ#allocating-multiple-threads-for-specific-operations
But I am not able to specify these threads. I have registered the handler as
container.Register(c => new RabbitMqServer());
var mqServer = container.Resolve();
mqServer.RegisterHandler(ServiceController.ExecuteMessage, noOfThreads: 4);
But it gives me error as RegisterHandler does not have parameter 'noOfThreads'. I am running the 4.0.24.0 version for ServiceStack RabbitMQ. Is there something else that I am missing here?
Upvotes: 1
Views: 399
Reputation: 882
The noOfThreads is only available on the RabbitMqServer and not a feature of the generic IMessageService. You need to cast the IMessageService you get back from the Container.Resolve() to a RabbitMqServer.
container.Register<IMessageService>(c => new RabbitMqServer());
var mqServer = (RabbitMqServer)container.Resolve<IMessageService>();
mqServer.RegisterHandler<CallBatchMessage>(ServiceController.ExecuteMessage, noOfThreads: 4);
Upvotes: 3