Oleksandr Hrebeniuk
Oleksandr Hrebeniuk

Reputation: 165

How to retrieve messages from turnout queue using MassTransit?

I'm trying to create an application using MassTransit and Azure Service Bus following this article http://docs.masstransit-project.com/en/latest/advanced/turnout.html.

After I started the application in Azure Service Bus has created two queues (one of them expired). And after I execute subscriber was created turnout queue and messages was moved to this queue from main. If subscriber works I can retrieve messages. If I stop subscriber (kill process or shutdown machine) messages still in turnout queue. Next time I execute subscriber it creates new turnout queue and I do not retrieve messages that were treated but not completed. So, how I can do not lose messages? And also how I can set the limit of max count of messages that treats in one node?

_busControl = Bus.Factory.CreateUsingAzureServiceBus(cfg =>
        {
            var host = cfg.Host("********", h =>
            {
                    //h.OperationTimeout = TimeSpan.FromMinutes(1);
            });
            cfg.MaxConcurrentCalls = 1;
            cfg.UseServiceBusMessageScheduler();
            cfg.TurnoutEndpoint<ISimpleRequest>(host, "test_longruning",
                e =>
                {
                    e.SuperviseInterval = TimeSpan.FromSeconds(30);
                    e.PartitionCount = 1;
                    e.SetJobFactory(async context =>
                        {
                            Console.WriteLine($"{DateTime.Now} Start Message: {context.Command.CustomerId}");
                            await Task.Delay(TimeSpan.FromMinutes(7), context.CancellationToken);
                            Console.WriteLine($"{DateTime.Now} End Message: {context.Command.CustomerId}");
                        });
                });
        });

Upvotes: 1

Views: 494

Answers (1)

Chris Patterson
Chris Patterson

Reputation: 33278

First, I should warn you that Turnout is very pre-production at this point. While it works in the happy path, the handling of service failures is not yet up to snuff. While the message time to live settings should end up with the commands back in the right queues, it hasn't been extensively tested.

That said, you can use ServiceBusExplorer to move messages back into the proper queues, that's how I do it. It's manual, but it's the only tool that really gives you complete control over your service bus environment.

Upvotes: 1

Related Questions