Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System;
using System.Threading.Tasks;
using NServiceBus;
using NServiceBus.Persistence;
class Program
{
static void Main(string[] args)
{
Start().GetAwaiter().GetResult();
}
static async Task Start()
{
const string connectionString = "Data Source=.\\SQLEXPRESS;Initial Catalog=nservicebus;Integrated Security=True";
var config = new EndpointConfiguration("OutboxMassiveSendRepro");
config.UseTransport<SqlServerTransport>().ConnectionString(connectionString);
config.UsePersistence<NHibernatePersistence>().ConnectionString(connectionString);
config.EnableOutbox();
config.SendFailedMessagesTo("error");
config.Recoverability().Immediate(i => i.NumberOfRetries(0));
config.Recoverability().Delayed(d => d.NumberOfRetries(0));
var endpoint = await Endpoint.Start(config).ConfigureAwait(false);
await endpoint.SendLocal(new TriggerMessage()).ConfigureAwait(false);
Console.WriteLine("Press <enter> to exit.");
Console.ReadLine();
}
}
class Trigegr : IHandleMessages<TriggerMessage>
{
public async Task Handle(TriggerMessage message, IMessageHandlerContext context)
{
for (var i = 0; i < 4000; i++)
{
await context.SendLocal(new ResultMessage());
}
}
}
class ResultHandler : IHandleMessages<ResultMessage>
{
public Task Handle(ResultMessage message, IMessageHandlerContext context)
{
Console.Write(".");
return Task.FromResult(0);
}
}
class TriggerMessage : IMessage
{
}
class ResultMessage : IMessage
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment