public static void Bootstrap(IContainer container) { // Initialize container var configuration = new BusConfiguration(); configuration.UseContainer <StructureMapBuilder>(c => c.ExistingContainer(container)); // Define message conventions ConventionsBuilder conventions = configuration.Conventions(); conventions.DefiningCommandsAs(MessageTypeConventions.EndsWith("Command")); conventions.DefiningEventsAs(MessageTypeConventions.EndsWith("Event")); conventions.DefiningMessagesAs(MessageTypeConventions.EndsWith("Message")); // Define features configuration.UseSerialization <JsonSerializer>(); configuration.UsePersistence <InMemoryPersistence>(); configuration.DisableFeature <Sagas>(); configuration.DisableFeature <MessageDrivenSubscriptions>(); configuration.DisableFeature <TimeoutManager>(); // Add the bus to the container var bus = Bus.CreateSendOnly(configuration); container.Configure(c => c.ForSingletonOf <ISendOnlyBus>().Use(x => bus).Named("__NAME__")); }
private void InitServiceBus(BusConfiguration config, IContainer container) { // Configure Logging NServiceBus.Logging.LogManager.Use <Log4NetFactory>(); // Configure container config.UseContainer <StructureMapBuilder>(c => c.ExistingContainer(container)); // Xml serialization makes for easy to read messages. config.UseSerialization <JsonSerializer>(); //Define conventions ConventionsBuilder conventions = config.Conventions(); conventions.DefiningCommandsAs(MessageTypeConventions.EndsWith("Command")); conventions.DefiningEventsAs(MessageTypeConventions.EndsWith("Event")); conventions.DefiningMessagesAs(MessageTypeConventions.EndsWith("Message")); // Keep it simple by default config.DisableFeature <SecondLevelRetries>(); config.DisableFeature <AutoSubscribe>(); config.DisableFeature <TimeoutManager>(); config.DisableFeature <DataBus>(); // Configure for MSMQ config.UseTransport <AzureServiceBusTransport>(); config.PurgeOnStartup(false); // Configure Saga Persistence config.UsePersistence <InMemoryPersistence>(); }