public void InitializeBus() { consumerContainer = new SimpleConsumerContainer(); Bus = new RogerBus(ConnectionFactory, consumerContainer, idGenerator: IdGenerator, sequenceGenerator: SequenceGenerator, options: new RogerOptions(prefetchCount: null /*no safety nets during tests*/)); Bus.Filters.Add(MessageFilters.ToArray()); localConnection = Helpers.CreateConnection(); TestModel = localConnection.CreateModel(); TestModel.ExchangeDeclare("TestExchange", ExchangeType.Topic, true /* to have the exchange there when restarting broker app within tests */, false, null); BeforeBusInitialization(); Bus.Start(); AfterBusInitialization(); }
public void Start_should_be_idempotent_on_an_already_started_bus() { var connectionFactory = Substitute.For<IConnectionFactory>(); var connection = Substitute.For<IConnection>(); connectionFactory.CreateConnection().Returns(connection); var model = Substitute.For<IModel>(); connection.CreateModel().Returns(model); model.QueueDeclare("", false, false, false, null).ReturnsForAnyArgs(new QueueDeclareOk("", 0, 0)); var bus = new RogerBus(connectionFactory); bus.Start(); bus.Start(); connectionFactory.Received(1).CreateConnection(); bus.Dispose(); }
public void Start(WaitHandle waitHandle) { var connectionFactory = new DefaultConnectionFactory(Constants.HostName); PublisherConfirmsProvider.DeclareExchange(connectionFactory); var bus = new RogerBus(connectionFactory); bus.Start(); StartPublishing(bus, waitHandle); }
public void Start_should_be_idempotent_on_an_already_started_bus() { var connectionFactory = Substitute.For <IConnectionFactory>(); var connection = Substitute.For <IConnection>(); connectionFactory.CreateConnection().Returns(connection); var model = Substitute.For <IModel>(); connection.CreateModel().Returns(model); model.QueueDeclare("", false, false, false, null).ReturnsForAnyArgs(new QueueDeclareOk("", 0, 0)); var bus = new RogerBus(connectionFactory); bus.Start(); bus.Start(); connectionFactory.Received(1).CreateConnection(); bus.Dispose(); }
public void Start(WaitHandle waitHandle) { var connectionFactory = new DefaultConnectionFactory(Constants.HostName); PublisherConfirmsProvider.DeclareExchange(connectionFactory); var bus = new RogerBus(connectionFactory, new SimpleConsumerContainer(new PublisherConfirmsConsumer())); bus.Start(); waitHandle.WaitOne(); bus.Dispose(); }
protected override void AfterBusInitialization() { secondaryConsumerContainer = new SimpleConsumerContainer(); BeforeSecondaryBusInitialization(); SecondaryBus = new RogerBus(new ManualConnectionFactory(Helpers.CreateConnectionOnAlternativePort), secondaryConsumerContainer, options: new RogerOptions(prefetchCount: null)); SecondaryBus.Start(); AfterSecondaryBusInitialization(); }
static void Main(string[] args) { var connectionFactory = new DefaultConnectionFactory("localhost"); using (var connection = connectionFactory.CreateConnection()) { var model = connection.CreateModel(); model.ExchangeDeclare("RabbusChat", ExchangeType.Topic, false); } var consumerContainer = new SimpleConsumerContainer(); var bus = new RogerBus(connectionFactory, consumerContainer, exchangeResolver: new StaticExchangeResolver("RabbusChat")); var chat = new ChatServer(bus); consumerContainer.Register(chat); bus.Start(); Console.ReadLine(); bus.Dispose(); }
static void Main(string[] args) { var connectionFactory = new DefaultConnectionFactory("localhost"); using(var connection = connectionFactory.CreateConnection()) { var model = connection.CreateModel(); model.ExchangeDeclare("RabbusChat", ExchangeType.Topic, false); } var consumerContainer = new SimpleConsumerContainer(); var bus = new RogerBus(connectionFactory, consumerContainer, exchangeResolver: new StaticExchangeResolver("RabbusChat")); var chat = new ChatServer(bus); consumerContainer.Register(chat); bus.Start(); Console.ReadLine(); bus.Dispose(); }