Created
April 18, 2017 10:53
-
-
Save SzymonPobiega/20ad01f120e3a9d57f109c9af51d0944 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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