public void DoIt() { // register our alternative container factory RabbitHutch.SetContainerFactory(() => { // create an instance of Windsor var windsorContainer = new WindsorContainer(); // wrap it in our implementation of EasyNetQ.IContainer return(new WindsorContainerWrapper(windsorContainer)); }); // now we can create an IBus instance, but it's resolved from // windsor, rather than EasyNetQ's default service provider. var bus = RabbitHutch.CreateBus("host=localhost"); var are = new AutoResetEvent(false); bus.Subscribe <MyMessage>("replace_container_spike", message => { Console.WriteLine(message.Text); are.Set(); }); bus.Publish(new MyMessage { Text = "Hello with Windsor!" }); are.WaitOne(1000); ((WindsorContainerWrapper)bus.Advanced.Container).Dispose(); bus.Dispose(); }
public static Autofac.IContainer RegisterAsEasyNetQContainerFactory(this ContainerBuilder builder) { var autofacAdapter = new AutofacAdapter(builder); RabbitHutch.SetContainerFactory(() => autofacAdapter); return(autofacAdapter.Container); }
public void TearDown() { if (bus != null) { bus.Dispose(); ((WindsorAdapter)bus.Advanced.Container).Dispose(); } RabbitHutch.SetContainerFactory(() => new DefaultServiceProvider()); }
public void Dispose() { if (bus != null) { bus.Dispose(); ((LightInjectAdapter)bus.Advanced.Container).Dispose(); } RabbitHutch.SetContainerFactory(() => new DefaultServiceProvider()); }
public RabbitMqGateway(string connectionString, int eventSubscriberThreadCount, int commandHandlerThreadCount, ILocator locator) { _eventSubscriberThreadCount = eventSubscriberThreadCount; _commandHandlerThreadCount = commandHandlerThreadCount; var adapter = new EasyNetQContainerAdapter(locator); RabbitHutch.SetContainerFactory(() => adapter); _externalMessageBus = RabbitHutch.CreateBus(connectionString, register => register.Register <IConsumerErrorStrategy, MyClass>()); _eventBus = locator.Resolve <Core.IEventBus>(); _commandHandlerFactory = locator.Resolve <ICommandHandlerFactory>(); var a = locator.Resolve <IConsumerErrorStrategy>(); }
public static Autofac.IContainer RegisterAsEasyNetQContainerFactory(this ContainerBuilder builder, Func <IBus> busCreator) { var adapter = new AutofacAdapter(builder); RabbitHutch.SetContainerFactory(() => adapter); var container = adapter.Container; var bus = busCreator(); adapter.Register(provider => bus); return(container); }
public void Start() { try { _container.Bind <IPersistCorrelation>().To <DefaultCorrelationPersistor>().InSingletonScope(); // Set the custom (ninject) ioc container RabbitHutch.SetContainerFactory(() => new CustomNinjectAdapter(_container)); // Create the rabbit Bus new BusBuilder().CreateMessageBus(s => s .Register <IEasyNetQLogger>(l => new Log4NetLogger(_container.Get <ILoggerFactory>().GetCurrentClassLogger())) .Register <IConventions>(c => c.Resolve <CustomConventions>()) .Register <IConsumerErrorStrategy>(e => e.Resolve <RetryErrorStrategy>()) .Register(e => EnableAuditing ? e.Resolve <HandlerAuditIntercepter>() as IProduceConsumeInterceptor : e.Resolve <DefaultInterceptor>() as IProduceConsumeInterceptor) ); // Scan for consumers and receivers _easyNetQScannerManager.ScanReceiversAndSubscribers(_container, QueueName); if (EnableErrorHandling) { // Initialize erro handling to files and database _errorHandlingManager.InitializeErrorHandling(_container, ServiceName, ManagementDatabaseConnection); } else { _logger.Info("No Error Management configured."); } if (EnableAuditing) { // Initialize auditing to files and database _auditHandlingManager.InitializeAuditing(_container, ServiceName, ManagementDatabaseConnection); } else { _logger.Info("No Audit Management configured."); } // Configure the quartz tasks _quartzTaskManager.InitializeScheduledTasks(_container); } catch (Exception ex) { _logger.Error(ex, "Error starting EasynetQ Generic Host."); throw; } }
public static void BootStrap() { var adapter = new EasyNetQ.DI.AutofacAdapter(new ContainerBuilder()); Container = adapter.Container; RabbitHutch.SetContainerFactory(() => { return(adapter); }); EasyNetQBus = EasyNetQ.RabbitHutch.CreateBus(Grit.Configuration.RabbitMQ.ACEQueueConnectionString, x => x.Register <IEasyNetQLogger, NullLogger>()); _builder = new ContainerBuilder(); BindFrameworkObjects(); BindBusinessObjects(); _builder.Update(Container); }
public void Should_be_able_to_replace_default_service_provider() { var bus = MockRepository.GenerateStub <IBus>(); var container = new MyAlternativeContainer(bus); try { RabbitHutch.SetContainerFactory(() => container); var resolvedBus = RabbitHutch.CreateBus("host=localhost"); resolvedBus.ShouldBeTheSameAs(bus); // Console.Out.WriteLine(container.RegisteredComponents); } finally { RabbitHutch.SetContainerFactory(() => new DefaultServiceProvider()); } }
public static void RegisterAsEasyNetQContainerFactory(this StructureMap.IContainer container) { RabbitHutch.SetContainerFactory(() => new StructureMapAdapter(container)); }
public void TearDown() { container.Dispose(); RabbitHutch.SetContainerFactory(() => new DefaultServiceProvider()); }
public static void RegisterAsEasyNetQContainerFactory(this IServiceContainer container) { RabbitHutch.SetContainerFactory(() => new LightInjectAdapter(container)); }
public static void RegisterAsEasyNetQContainerFactory(this IWindsorContainer container) { RabbitHutch.SetContainerFactory(() => new WindsorAdapter(container)); }
public static void RegisterAsEasyNetQContainerFactory(this IKernel container) { RabbitHutch.SetContainerFactory(() => new NinjectAdapter(container)); }
public static void RegisterAsEasyNetQContainerFactory(this Container container) { RabbitHutch.SetContainerFactory(() => new SimpleInjectorAdapter(container)); }