public bool Start(HostControl hostControl)
        {
            _log.Info("Creating bus...");

            _busControl = Bus.Factory.CreateUsingRabbitMq(x =>
            {
                IRabbitMqHost host = x.Host(new Uri(ConfigurationManager.AppSettings["RabbitMQHost"]), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });

                x.ReceiveEndpoint(host, ConfigurationManager.AppSettings["ServiceQueueName"],
                    e => { e.Consumer<RequestConsumer>(); });

                x.ReceiveEndpoint(host, ConfigurationManager.AppSettings["ValidationAddress"],
                    e => { e.Consumer<ValidateConsumer>(); });
            });

            _log.Info("Starting bus...");

            _busControl.Start();

            return true;
        }
        public void SetupAzureServiceBusTestFixture()
        {
            _bus = CreateBus();

            _bus.ConnectReceiveEndpointObserver(new ReceiveEndpointObserver());

            _busHandle = _bus.Start();
            try
            {
                _busSendEndpoint = _bus.GetSendEndpoint(_bus.Address).Result;
                _busSendEndpoint.ConnectSendObserver(_sendObserver);

                _inputQueueSendEndpoint = _bus.GetSendEndpoint(_inputQueueAddress).Result;
                _inputQueueSendEndpoint.ConnectSendObserver(_sendObserver);
            }
            catch (Exception)
            {
                try
                {
                    using (var tokenSource = new CancellationTokenSource(TestTimeout))
                    {
                        _bus.Stop(tokenSource.Token);
                    }
                }
                finally
                {
                    _busHandle = null;
                    _bus = null;
                }

                throw;
            }
        }
        public void SetupSecondAzureServiceBusTestFixture()
        {
            _secondBus = CreateSecondBus();

            _secondBusHandle = _secondBus.Start();
            try
            {
                _secondBusSendEndpoint = Await(() => _secondBus.GetSendEndpoint(_secondBus.Address));

                _secondInputQueueSendEndpoint = Await(() => _secondBus.GetSendEndpoint(_secondInputQueueAddress));
            }
            catch (Exception)
            {
                try
                {
                    using (var tokenSource = new CancellationTokenSource(TestTimeout))
                    {
                        _secondBusHandle.Stop(tokenSource.Token);
                    }
                }
                finally
                {
                    _secondBusHandle = null;
                    _secondBus = null;
                }

                throw;
            }
        }
 private void InitializeMessageBus()
 {
     Log4NetLogger.Use();
     _busControl = Bus.Factory.CreateUsingRabbitMq(x =>
       x.Host(GetDefaultRabbitMqBusUri(), h => { }));
     _busHandle = _busControl.Start();
 }
        internal void Stop()
        {
            _bus = null;

            _activityExecuteBuses.Clear();
            _activityCompensateBuses.Clear();
        }
        protected void Application_Start()
        {
            var container = new Container();
            HttpContext.Current.Application.Add("Container", container); // Add the container to the context so the ObjectFactory can use it later.

            container.Configure(cfg =>
            {
                cfg.AddRegistry<ServiceRegistry>();
                cfg.AddRegistry<LoggerRegistry>();
                cfg.AddRegistry<MessagingRegistry>();
            });

            _busControl = MassTransitConfig.ConfigureBus(container);

            container.Configure(cfg =>
            {
                cfg.For<IBusControl>().Use(_busControl);
                cfg.Forward<IBus, IBusControl>(); // Doesn't seem to work
            });

            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            LoggingConfig.ConfigureLog4Net();

            _busControl.Start();
        }
 public RabbitBus(Action<IRabbitMqReceiveEndpointConfigurator> receiveEndpoint = null)
 {
     var host = ConfigurationManager.AppSettings["RabbitMQ.Host"];
     var user = ConfigurationManager.AppSettings["RabbitMQ.Username"];
     var password = ConfigurationManager.AppSettings["RabbitMQ.Password"];
     _bus = ConfigureBus(host, user, password, receiveEndpoint);
 }
Exemple #8
0
 private static void Repeat(IBusControl bus, string command, int times)
 {
     for (int i = 0; i < times; i++)
     {
         if (command == "approval")
         {
             bus.Publish<ReportApproval>(new ReportApprovalMessage
             {
                 Approved = (times % 2) == 0,
                 ApprovalNotes = "this is the " + i + " time "
             });
         }
         else if (command == "newref")
         {
             bus.Publish<NewReferral>(new NewReferralMessage
             {
                 Name = "Mr Michael Shanks the " + i,
                 DateOfBirth = DateTime.Now.AddYears(-20),
                 NoOfAuthorisations = i
             });
         }
         else
         {
             throw new Exception("Could not find command " + command);
         }
     }
 }
 public MassTransitPublisher()
 {
     Log4NetLogger.Use();
     _bus = Bus.Factory.CreateUsingRabbitMq(x =>
       x.Host(new Uri("rabbitmq://localhost/"), h => { }));
     var busHandle = _bus.Start();
 }
        public bool Start(HostControl hostControl)
        {
            _log.Info("Creating bus...");

            _sagaRepository = GetSagaRepository();

            ITrackingEventWriter writer = GetTrackingEventWriter();

            _busControl = Bus.Factory.CreateUsingRabbitMq(x =>
            {
                var host = x.Host(GetHostAddress(), h =>
                {
                    h.Username(ConfigurationManager.AppSettings["RabbitMQUsername"]);
                    h.Password(ConfigurationManager.AppSettings["RabbitMQPassword"]);
                });

                x.ReceiveEndpoint(host, ConfigurationManager.AppSettings["BookingStateQueueName"], e =>
                {
                    e.StateMachineSaga(_stateMachine, _sagaRepository);
                });

                x.ReceiveEndpoint(host, ConfigurationManager.AppSettings["EventTrackingQueueName"], e =>
                {
                    e.Consumer(() => new EventTrackingConsumer(writer));
                });
            });

            _log.Info("Starting bus...");

            _busHandle = _busControl.Start();

            TaskUtil.Await(() => _busHandle.Ready);

            return true;
        }
        static IRequestClient<ISimpleRequest, ISimpleResponse> CreateRequestClient(IBusControl busControl)
        {
            var serviceAddress = new Uri(ConfigurationManager.AppSettings["ServiceAddress"]);
            IRequestClient<ISimpleRequest, ISimpleResponse> client =
                busControl.CreateRequestClient<ISimpleRequest, ISimpleResponse>(serviceAddress, TimeSpan.FromSeconds(10));

            return client;
        }
        private void InitializeMessageBus()
        {
            Log4NetLogger.Use();
            _busControl = Bus.Factory.CreateUsingRabbitMq(x =>
            {
                var host = x.Host(MessageBusPublisher.GetDefaultRabbitMqBusUri(), h => { });

                x.ReceiveEndpoint(host, "OberSane_ServerNotificationSubscriber", e =>
                  e.Consumer<ServerNotificationConsumer>());
            });
        }
        public bool Start(HostControl hostControl)
        {
            _log.Info("Creating bus...");

            _machine = new ShoppingCartStateMachine();

            SagaDbContextFactory sagaDbContextFactory =
                () => new SagaDbContext<ShoppingCart, ShoppingCartMap>(SagaDbContextFactoryProvider.ConnectionString);

            _repository = new Lazy<ISagaRepository<ShoppingCart>>(
                () => new EntityFrameworkSagaRepository<ShoppingCart>(sagaDbContextFactory));

            _busControl = Bus.Factory.CreateUsingRabbitMq(x =>
            {
                IRabbitMqHost host = x.Host(new Uri(ConfigurationManager.AppSettings["RabbitMQHost"]), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });

                x.ReceiveEndpoint(host, "shopping_cart_state", e =>
                {
                    e.PrefetchCount = 8;
                    e.StateMachineSaga(_machine, _repository.Value);
                });

                x.ReceiveEndpoint(host, ConfigurationManager.AppSettings["SchedulerQueueName"], e =>
                {
                    x.UseMessageScheduler(e.InputAddress);
                    e.PrefetchCount = 1;

                    e.Consumer(() => new ScheduleMessageConsumer(_scheduler));
                    e.Consumer(() => new CancelScheduledMessageConsumer(_scheduler));
                });
            });

            _log.Info("Starting bus...");

            try
            {
                _busHandle = _busControl.Start();

                _scheduler.JobFactory = new MassTransitJobFactory(_busControl);

                _scheduler.Start();
            }
            catch (Exception)
            {
                _scheduler.Shutdown();
                throw;
            }

            return true;
        }
 static MassTransitWithRabbitMQ()
 {
     _bus = Bus.Factory.CreateUsingRabbitMq(x =>
     {
         x.Host(new Uri(_baseurl), h =>
         {
             h.Username("iot");
             h.Password("iot");
         });
     });
     _handle = _bus.Start();
 }
        public bool Start(HostControl hostControl)
        {
            _settings = new Settings();
            _fetchAvatarActivitySettings = new FetchAvatarSettings();

            _log.Info("Creating bus...");


            _busControl = Bus.Factory.CreateUsingRabbitMq(x =>
            {
                var host = x.Host(GetHostAddress(), h =>
                {
                    h.Username(ConfigurationManager.AppSettings["RabbitMQUsername"]);
                    h.Password(ConfigurationManager.AppSettings["RabbitMQPassword"]);
                });

                x.ReceiveEndpoint(host, ConfigurationManager.AppSettings["BookMeetingQueueName"], e =>
                {
                    e.Consumer(() =>
                    {
                        var handler = new BookingRequestHandler(_settings);

                        return new BookMeetingConsumer(handler);
                    });
                });

                x.ReceiveEndpoint(host, ConfigurationManager.AppSettings["FetchAvatarActivityQueue"], e =>
                {
                    e.ExecuteActivityHost<FetchAvatarActivity, FetchAvatarArguments>(() => new FetchAvatarActivity(_fetchAvatarActivitySettings));
                });

                x.ReceiveEndpoint(host, ConfigurationManager.AppSettings["ReserveRoomCompensateQueue"], c =>
                {
                    var compensateAddress = c.InputAddress;

                    c.ExecuteActivityHost<ReserveRoomActivity, ReserveRoomArguments>();

                    x.ReceiveEndpoint(host, ConfigurationManager.AppSettings["ReserveRoomExecuteQueue"], e =>
                    {
                        e.ExecuteActivityHost<ReserveRoomActivity, ReserveRoomArguments>(compensateAddress);
                    });
                });
            });

            _log.Info("Starting bus...");

            _busHandle = _busControl.Start();

            TaskUtil.Await(() => _busHandle.Ready);

            return true;
        }
        public SimulateVehicleDataService(IBusControl bus, IRoutePlanner routePlanner)
        {
            if (bus == null) throw new ArgumentNullException(nameof(bus));
            if (routePlanner == null) throw new ArgumentNullException(nameof(routePlanner));

            _bus = bus;
            _routePlanner = routePlanner;

            _vehicleSimulations = CreateSimulators(6);

            _timer = new Timer(100) { AutoReset = true };
            _timer.Elapsed += UpdateSimulators;
        }
 public void Start()
 {
     _busControl = Bus.Factory.CreateUsingRabbitMq(x =>
     {
         _host = x.Host(new Uri(_baseurl), h =>
         {
             h.Username("iot");
             h.Password("iot");
         });
         x.ReceiveEndpoint(_host, "rest_requests", e => { e.Consumer<RequestConsumer>(); });
     });
     _busHandle = _busControl.Start();
 }
        public bool Start(HostControl hostControl)
        {
            _log.Info("Creating bus...");

            _metrics = new RoutingSlipMetrics("Routing Slip");
            _activityMetrics = new RoutingSlipMetrics("Validate Activity");

            _machine = new RoutingSlipStateMachine();
            _provider = new SQLiteSessionFactoryProvider(false, typeof(RoutingSlipStateSagaMap));
            _sessionFactory = _provider.GetSessionFactory();

            _repository = new NHibernateSagaRepository<RoutingSlipState>(_sessionFactory);

            _busControl = Bus.Factory.CreateUsingRabbitMq(x =>
            {
                IRabbitMqHost host = x.Host(new Uri(ConfigurationManager.AppSettings["RabbitMQHost"]), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });

                x.ReceiveEndpoint(host, "routing_slip_metrics", e =>
                {
                    e.PrefetchCount = 100;
                    e.UseRetry(Retry.None);
                    e.Consumer(() => new RoutingSlipMetricsConsumer(_metrics));
                });

                x.ReceiveEndpoint(host, "routing_slip_activity_metrics", e =>
                {
                    e.PrefetchCount = 100;
                    e.UseRetry(Retry.None);
                    e.Consumer(() => new RoutingSlipActivityConsumer(_activityMetrics, "Validate"));
                });

                x.ReceiveEndpoint(host, "routing_slip_state", e =>
                {
                    e.PrefetchCount = 8;
                    e.UseConcurrencyLimit(1);
                    e.StateMachineSaga(_machine, _repository);
                });
            });

            _log.Info("Starting bus...");

            _busHandle = _busControl.Start();

            return true;
        }
Exemple #19
0
        public void Start()
        {
            _container = CreateContainer();
            _bus = CreateBus(_container);
            _container.Inject(_bus);
            _bus.Start();

            var rdb = _container.GetInstance<ReadStoreDb>();
            var wdb = _container.GetInstance<MyContext>();
            rdb.Database.Initialize(true);
            wdb.Database.Initialize(true);

            Thread.Sleep(2000);

            DoStuff();
        }
        public bool Start(HostControl hostControl)
        {
            int workerThreads;
            int completionPortThreads;
            ThreadPool.GetMinThreads(out workerThreads, out completionPortThreads);
            Console.WriteLine("Min: {0}", workerThreads);

            ThreadPool.SetMinThreads(200, completionPortThreads);

            _log.Info("Creating bus...");

            _busControl = Bus.Factory.CreateUsingRabbitMq(x =>
            {
                IRabbitMqHost host = x.Host(new Uri(ConfigurationManager.AppSettings["RabbitMQHost"]), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });

                x.ReceiveEndpoint(host, ConfigurationManager.AppSettings["ValidateActivityQueue"], e =>
                {
                    e.PrefetchCount = 100;
                    e.ExecuteActivityHost<ValidateActivity, ValidateArguments>(
                        DefaultConstructorExecuteActivityFactory<ValidateActivity, ValidateArguments>.ExecuteFactory);
                });

                string compQueue = ConfigurationManager.AppSettings["CompensateRetrieveActivityQueue"];

                Uri compAddress = host.Settings.GetQueueAddress(compQueue);

                x.ReceiveEndpoint(host, ConfigurationManager.AppSettings["RetrieveActivityQueue"], e =>
                {
                    e.PrefetchCount = 100;
                    //                    e.Retry(Retry.Selected<HttpRequestException>().Interval(5, TimeSpan.FromSeconds(1)));
                    e.ExecuteActivityHost<RetrieveActivity, RetrieveArguments>(compAddress);
                });

                x.ReceiveEndpoint(host, ConfigurationManager.AppSettings["CompensateRetrieveActivityQueue"],
                    e => e.CompensateActivityHost<RetrieveActivity, RetrieveLog>());
            });

            _log.Info("Starting bus...");

            _busHandle = _busControl.Start();

            return true;
        }
        public bool Start(HostControl hostControl)
        {
            _bus = Bus.Factory.CreateUsingRabbitMq(cfg =>
            {
                var host = cfg.Host(new Uri("rabbitmq://localhost"), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });

                cfg.ReceiveEndpoint(host, "checkin", e => { e.Consumer<CheckinCommandConsumer>(); });
            });

            _bus.Start();

            return true;
        }
        public void GivenARunningBusThatIsListeningToABigTestMessageThatIsUsingMongoMessageDataRepository()
        {
            _busControl = Bus.Factory.CreateUsingInMemory(cfg =>
            {
                cfg.ReceiveEndpoint("test-" + new Guid().ToString(), ep =>
                {
                    ep.Handler<BigTestMessage>((context) => { _bigTestMessages.Add(context.Message);
                                                                return Task.FromResult(0);
                    });

                    ep.UseMessageData<BigTestMessage>(MessageDataRepository.Instance);
                });
            });

            _busHandle = _busControl.Start();
            _busHandle.Ready.Wait();
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            _bus = MassTransit.Bus.Factory.CreateUsingRabbitMq(x =>
            {
                x.Host(new Uri(ConfigurationManager.AppSettings["RabbitMQHost"]), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });
            });

            _busHandle = _bus.Start();
        }
Exemple #24
0
        public MassTransitBus(List<BusConsumer> consumers )
        {
            _configManager = new RequiredConfigManager();
            _bus = Bus.Factory.CreateUsingRabbitMq(cfg =>
            {

                cfg.Host(new Uri(_configManager.Get("Bus.Url")), h =>
                {
                    h.Username(_configManager.Get("Bus.UserName"));
                    h.Password(_configManager.Get("Bus.Password"));
                });

                foreach (BusConsumer consumer in consumers)
                {
                    cfg.ReceiveEndpoint(consumer.QueueName, consumer.ConsumerAction);
                }
            });

            _bus.Start();
        }
        private void ConfigureServiceBus()
        {
            _busControl = Bus.Factory.CreateUsingRabbitMq(x =>
            {
                IRabbitMqHost host = x.Host(new Uri(ConfigurationManager.AppSettings["RabbitMQHost"]), h =>
                {
                    h.Username(ConfigurationManager.AppSettings["RabbitMQUser"]);
                    h.Password(ConfigurationManager.AppSettings["RabbitMQPassword"]);
                });

                x.ReceiveEndpoint(host, "clearing", e =>
                {
                    e.Durable = true;
                    e.StateMachineSaga(_machine, _repository.Value);
                    e.UseConsoleLog(async (ev, lc) => string.Format("Received message Id:{0} of type: {1}", ev.MessageId, string.Join(",",ev.SupportedMessageTypes)));
                });
            });

            _busHandle = _busControl.Start();
        }
        public void SetupSecondAzureServiceBusTestFixture()
        {
            _secondBus = CreateSecondBus();

            _secondBusHandle = _secondBus.Start();
            try
            {
                _secondBusSendEndpoint = Await(() => _secondBus.GetSendEndpoint(_secondBus.Address));

                _secondInputQueueSendEndpoint = Await(() => _secondBus.GetSendEndpoint(_secondInputQueueAddress));
            }
            catch (Exception ex)
            {
                Console.WriteLine("The bus creation failed: {0}", ex);

                _secondBusHandle.Stop();

                throw;
            }
        }
        public bool Start(HostControl hostControl)
        {
            try
            {
                Uri serviceBusUri = _configurationProvider.GetServiceBusUri();

                if (serviceBusUri.Scheme.Equals("rabbitmq", StringComparison.OrdinalIgnoreCase))
                {
                    _bus = Bus.Factory.CreateUsingRabbitMq(busConfig =>
                    {
                        IRabbitMqHost host = busConfig.Host(serviceBusUri, h => _configurationProvider.GetHostSettings(h));
                        busConfig.UseJsonSerializer();

                        busConfig.ReceiveEndpoint(host, _queueName, endpoint =>
                        {
                            endpoint.PrefetchCount = (ushort)_consumerLimit;

                            var partitioner = endpoint.CreatePartitioner(_consumerLimit);

                            endpoint.Consumer(() => new ScheduleMessageConsumer(_scheduler), x =>
                                x.ConfigureMessage<ScheduleMessage>(m => m.UsePartitioner(partitioner, p => p.Message.CorrelationId)));
                            endpoint.Consumer(() => new CancelScheduledMessageConsumer(_scheduler), x =>
                                x.ConfigureMessage<CancelScheduledMessage>(m => m.UsePartitioner(partitioner, p => p.Message.TokenId)));
                        });
                    });
                }

                _busHandle = _bus.Start();

                _scheduler.JobFactory = new MassTransitJobFactory(_bus);

                _scheduler.Start();
            }
            catch (Exception)
            {
                _scheduler.Shutdown();
                throw;
            }

            return true;
        }
Exemple #28
0
        public bool Start(HostControl hostControl)
        {
            NLogLogger.Use();

            var container = new Container(cfg =>
            {
                // register each consumer
                cfg.ForConcreteType<SimpleRequestConsumer>();
                cfg.ForConcreteType<ComplexRequestConsumer>();
                cfg.ForConcreteType<MessageRequestConsumer>();

                //or use StructureMap's excellent scanning capabilities
            });

            Console.WriteLine("Creating bus...");
            _log.Info("Creating bus");
            _busControl = Bus.Factory.CreateUsingRabbitMq(x =>
            {
                IRabbitMqHost host = x.Host(new Uri("rabbitmq://localhost/"), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });
                x.UseNLog();
                  x.AutoDelete = true;
                x.ReceiveEndpoint(host, "request_service", ec => { ec.LoadFrom(container); });

            });

            //container.Configure(cfg =>
            //{
            //    cfg.For<IBusControl>().Use(_busControl);
            //    cfg.Forward<IBus, IBusControl>();
            //});

            Console.WriteLine("Starting bus...");

            _busControl.Start();

            return true;
        }
        public bool Start(HostControl hostControl)
        {
            this.log.Info("Creating bus...");

            this.busControl = Bus.Factory.CreateUsingRabbitMq(x =>
            {
                IRabbitMqHost host = x.Host(new Uri(ConfigurationManager.AppSettings["RabbitMQHost"]), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });

                x.ReceiveEndpoint(host, e => { e.Consumer<Consumer>(); });
            });

            this.log.Info("Starting bus...");

            this.busControl.Start();

            return true;
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            _bus = MassTransit.Bus.Factory.CreateUsingRabbitMq(x =>
            {
                x.Host(GetHostAddress(), h =>
                {
                    h.Username(ConfigurationManager.AppSettings["RabbitMQUsername"]);
                    h.Password(ConfigurationManager.AppSettings["RabbitMQPassword"]);
                });
            });

            _busHandle = _bus.Start();

            TaskUtil.Await(() => _busHandle.Ready);
        }
Exemple #31
0
 public StreamOnlineConsumer(DiscordShardedClient client, IUnitOfWorkFactory factory, IBusControl bus, IEnumerable <ILiveBotMonitor> monitors)
 {
     _client   = client;
     _work     = factory.Create();
     _bus      = bus;
     _monitors = monitors;
 }
Exemple #32
0
 public MasstransitHostedService(IBusControl busControl) => _busControl = busControl;
 public DefaultBusInstance(IBusControl busControl)
 {
     BusControl = busControl;
 }
Exemple #34
0
 public TransportBusInstance(IBusControl busControl, IHostConfiguration hostConfiguration)
     : this(busControl, hostConfiguration, new RiderConnectable())
 {
 }
Exemple #35
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime lifetime, IBusControl bus, UsersContext usersContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseStatusCodePages();
            }

            usersContext.Database.Migrate();

            app.UseMvc();

            var busHandle = TaskUtil.Await(() => bus.StartAsync());

            lifetime.ApplicationStopping
            .Register(() => busHandle.Stop());
        }
Exemple #36
0
        /// <summary>
        /// Gets the send endpoint.
        /// </summary>
        /// <param name="bus">The bus.</param>
        /// <param name="queueName">Name of the queue.</param>
        /// <returns></returns>
        public override ISendEndpoint GetSendEndpoint(IBusControl bus, string queueName)
        {
            var url = $"sb://{GetHost()}{queueName}";

            return(bus.GetSendEndpoint(new Uri(url)).Result);
        }
 public SenderHostedService(IBusControl eventsEngine, ILogger <SenderHostedService> logger)
 {
     this.eventsEngine = eventsEngine;
     this.logger       = logger;
 }
Exemple #38
0
 public BusService(IBusControl busControl)
 {
     _busControl = busControl;
 }
 protected BusInstance(IBusControl busControl)
 {
     _busControl = busControl;
 }
 public HostedServiceConsume(ILogger <HostedServiceConsume> logger, IBusControl bus)
 {
     _logger = logger;
     _bus    = bus;
 }
 public MasstransitBus(IBusControl masstransitBus)
 {
     _masstransitBus = masstransitBus ?? throw new ArgumentNullException(nameof(masstransitBus));
 }
 public SpectrumBackstage(IBusControl busControl)
 {
     _busControl = busControl;
 }
 public PublisherService(IBusControl bus, Counter counter, ILogger <PublisherService> logger)
 {
     _bus     = bus;
     _counter = counter;
     _logger  = logger;
 }
Exemple #44
0
 public OrderPublisher(IBusControl bus)
 {
     Bus = bus;
 }
Exemple #45
0
 public HomeController(ILogger <HomeController> logger, IBusControl busControl, IPublishEndpoint publishEndpoint)
 {
     _logger          = logger;
     _busControl      = busControl;
     _publishEndpoint = publishEndpoint;
 }
Exemple #46
0
 public MembershipService(IBusControl busControl, IMapper mapper, AppDbContext appDbContext)
 {
     _busControl   = busControl;
     _mapper       = mapper;
     _appDbContext = appDbContext;
 }
 public BusService(IBusControl bus)
 {
     _bus = bus;
 }
Exemple #48
0
 public OrderController(ILogger <OrderController> logger, IBusControl bus)
 {
     _logger = logger;
     _bus    = bus;
 }
Exemple #49
0
        static void Main(string[] args)
        {
            string rabbitMqAddress = "rabbitmq://localhost:5672";
            string virtualHost     = "/";
            string rabbitMqQueue   = "StayWell.SWIQ.CreateParticipant";

            Uri rabbitMqRootUri = new Uri(string.Concat(rabbitMqAddress, virtualHost));

            IBusControl rabbitBusControl = Bus.Factory.CreateUsingRabbitMq(rabbit =>
            {
                rabbit.Host(rabbitMqRootUri, settings =>
                {
                    settings.Password("guest");
                    settings.Username("guest");
                });
            });

            rabbitBusControl.Start();

            Task <ISendEndpoint> sendEndpointTask = rabbitBusControl.GetSendEndpoint(new Uri(string.Concat(rabbitMqAddress, virtualHost, rabbitMqQueue)));
            ISendEndpoint        sendEndpoint     = sendEndpointTask.Result;

            do
            {
                Console.WriteLine("Enter message type ('command', 'event', 'rpc') (or 'quit' to exit)");
                Console.Write("> ");
                string type = Console.ReadLine();

                if ("quit".Equals(type, StringComparison.OrdinalIgnoreCase))
                {
                    break;
                }

                Console.WriteLine("Enter data");
                Console.Write("> ");
                string data = Console.ReadLine();

                if (type.ToLower() == "command")
                {
                    sendEndpoint.Send <ICreateParticipant>(new
                    {
                        CreationDate = DateTime.UtcNow,
                        Data         = data
                    });
                }
                else if (type.ToLower() == "event")
                {
                    rabbitBusControl.Publish <IParticipantUpdated>(new
                    {
                        DateUpdated = DateTime.UtcNow,
                        FirstName   = data
                    });
                }
                else if (type.ToLower() == "rpc")
                {
                    IRequestClient <ICreateParticipant, ICreateParticipantResponse> client =
                        rabbitBusControl.CreateRequestClient <ICreateParticipant, ICreateParticipantResponse>(new Uri(string.Concat(rabbitMqAddress, virtualHost, rabbitMqQueue)), TimeSpan.FromSeconds(10));

                    Task.Run(async() =>
                    {
                        ICreateParticipantResponse response = await client.Request(new CreateParticipant
                        {
                            CreationDate = DateTime.UtcNow,
                            Data         = data
                        });

                        Console.WriteLine("Participant creation response: ParticipantId: {0}, Data: {1}", response.ParticipantId, response.Data);
                    }).Wait();
                }
                else
                {
                    Console.WriteLine("Wrong message type!");
                    Console.Write("> ");
                }
            }while (true);

            rabbitBusControl.Stop();
        }
Exemple #50
0
 public CustomerDisabledNotificationHandler(IMediator mediator, ILoggerFactory logger, IBusControl busControl)
     : base(mediator, logger.CreateLogger <CustomerDisabledNotificationHandler>())
 {
     _busControl = busControl;
 }
Exemple #51
0
 public void Start()
 {
     _busControl = _messageBus.Create();
     _busControl.Start();
 }
Exemple #52
0
 public TransportBusInstance(IBusControl busControl, IHostConfiguration hostConfiguration, RiderConnectable riders)
 {
     _riders           = riders;
     BusControl        = busControl;
     HostConfiguration = hostConfiguration;
 }
Exemple #53
0
 public Service2Controller(IBusControl publishEndpoint)
 {
     PublishEndpoint = publishEndpoint;
 }
Exemple #54
0
 public BusHostedService(IBusControl busControl)
 {
     _busControl = busControl;
 }
Exemple #55
0
 public MassTransitHostedService(IBusControl busControl)
 {
     this.busControl = busControl;
 }
Exemple #56
0
 public SkillService(IBusControl busControl) : base(busControl)
 {
 }
Exemple #57
0
 /// <summary>
 /// Starts a bus, throwing an exception if the bus does not start
 /// It is a wrapper of the async method `StartAsync`
 /// </summary>
 /// <param name="busControl">The bus handle</param>
 public static void Start(this IBusControl busControl)
 {
     TaskUtil.Await(() => busControl.StartAsync());
 }
Exemple #58
0
 public ShopsController(IBusControl busControl)
 {
     _busControl = busControl;
 }
 public OrderWorker(IBusControl busControl)
 {
     _busControl = busControl;
 }
Exemple #60
0
 public GenerateScorecardResponseConsumer(IBusControl bus)
 {
     _bus = bus;
 }