public async Task SetupSecondAzureServiceBusTestFixture() { _secondBus = CreateSecondBus(); _secondBusHandle = await _secondBus.StartAsync(); try { _secondBusSendEndpoint = await _secondBus.GetSendEndpoint(_secondBus.Address); _secondInputQueueSendEndpoint = await _secondBus.GetSendEndpoint(_secondInputQueueAddress); } catch (Exception) { try { using (var tokenSource = new CancellationTokenSource(TestTimeout)) { await _secondBusHandle.StopAsync(tokenSource.Token); } } finally { _secondBusHandle = null; _secondBus = null; } throw; } }
public BusTestScenario(TimeSpan timeout, IBusControl busControl) { _timeout = timeout; _busControl = busControl; Received = new ReceivedMessageList(timeout); _skipped = new ReceivedMessageList(timeout); _published = new PublishedMessageList(timeout); _tokenSource = new CancellationTokenSource(timeout); CancellationToken = _tokenSource.Token; var testSendObserver = new TestSendObserver(timeout); Sent = testSendObserver.Messages; _subjectSendEndpoint = GetSendEndpoint(testSendObserver); var consumeObserver = new TestConsumeObserver(timeout); Received = consumeObserver.Messages; busControl.ConnectConsumeObserver(consumeObserver); _busHandle = _busControl.StartAsync(); }
public bool Start(HostControl hostControl) { if (_log.IsInfoEnabled) _log.InfoFormat("Creating bus for hosted service: {0}", _serviceName); try { _busControl = _hostBusFactory.CreateBus(_serviceConfigurator, _serviceName); _busHandle = TaskUtil.Await(() => _busControl.StartAsync()); if (_log.IsInfoEnabled) _log.InfoFormat("Created bus for hosted service: {0}", _serviceName); return true; } catch (Exception ex) { if (_log.IsErrorEnabled) _log.Error($"Creating bus for hosted service: {_serviceName}", ex); throw; } }
/// <inheritdoc/> public async Task StartAsync(CancellationToken cancellationToken) { await bus.StartAsync(cancellationToken).ConfigureAwait(false); }
public override async Task StartAsync(CancellationToken cancellationToken) { await _bus.StartAsync(cancellationToken).ConfigureAwait(false); Log.Information("BUS started !"); }
public async Task StartAsync(CancellationToken cancellationToken) { await _bus.StartAsync(); }
/// <summary> /// Start MassTransit bus /// </summary> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task StartAsync(CancellationToken cancellationToken) { _logger.LogInformation("Starting bus for ConsoleA"); await _bus.StartAsync(cancellationToken).ConfigureAwait(false); }
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("courier"); h.Password("pear"); }); 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.GetSendAddress(compQueue); x.ReceiveEndpoint(host, ConfigurationManager.AppSettings["RetrieveActivityQueue"], e => { e.PrefetchCount = 100; //e.UseRetry(Retry.Selected<ArgumentNullException>().Interval(5, TimeSpan.FromSeconds(1))); //e.ExecuteActivityHost<RetrieveActivity, RetrieveArguments>(compAddress); e.ExecuteActivityHost <RetrieveActivity, RetrieveArguments>(compAddress, h => { h.UseRetry(rcfg => { rcfg.Interval(5, TimeSpan.FromSeconds(1)); //rcfg.Handle<ArgumentNullException>(y=> //{ // var a = true; // return a; //}); }); }); }); //x.ReceiveEndpoint(host, ConfigurationManager.AppSettings["RetrieveActivityQueue"], e => //{ // e.PrefetchCount = 100; // e.ExecuteActivityHost<RetrieveActivity, RetrieveArguments>(compAddress, h => // { // h.UseRetry(rcfg => rcfg.Interval(5, TimeSpan.FromSeconds(1))); // }); //}); x.ReceiveEndpoint(host, ConfigurationManager.AppSettings["CompensateRetrieveActivityQueue"], e => e.CompensateActivityHost <RetrieveActivity, RetrieveLog>()); }); _log.Info("Starting bus..."); _busControl.StartAsync().Wait(); return(true); }
public BusHandle Start() { return(TaskUtil.Await(() => _bus.StartAsync())); }
public Task StartAsync(CancellationToken cancellationToken) { _timer = new Timer(DoWork, null, TimeSpan.Zero, TimeSpan.FromSeconds(5)); return(_busControl.StartAsync(cancellationToken)); }
/// <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()); }
public async Task <BusHandle> Start() { return(await _bus.StartAsync()); }
public MassTransitSB(IOptions <BusConfiguration> configuration, ISubscribe subscribe) { _Subscriber = subscribe; _Bus = GetBusInstance(configuration); _Bus.StartAsync().Wait(); }
public async Task Should_support_the_new_syntax() { ServiceBusTokenProviderSettings settings = new TestAzureServiceBusAccountSettings(); var serviceBusNamespace = Configuration.ServiceNamespace; Uri serviceUri = AzureServiceBusEndpointUriCreator.Create( serviceBusNamespace, "MassTransit.Azure.ServiceBus.Core.Tests" ); var completed = TaskUtil.GetTask <A>(); IBusControl bus = Bus.Factory.CreateUsingAzureServiceBus(x => { IServiceBusHost host = x.Host(serviceUri, h => { h.SharedAccessSignature(s => { s.KeyName = settings.KeyName; s.SharedAccessKey = settings.SharedAccessKey; s.TokenTimeToLive = settings.TokenTimeToLive; s.TokenScope = settings.TokenScope; }); }); x.ReceiveEndpoint(host, "input_queue", e => { e.PrefetchCount = 16; e.UseExecute(context => Console.WriteLine( $"Received (input_queue): {context.ReceiveContext.TransportHeaders.Get("MessageId", "N/A")}, Types = ({string.Join(",", context.SupportedMessageTypes)})")); e.Handler <A>(async context => completed.TrySetResult(context.Message)); // Add a message handler and configure the pipeline to retry the handler // if an exception is thrown e.Handler <A>(Handle, h => { h.UseRetry(r => r.Interval(5, 100)); }); }); }); BusHandle busHandle = await bus.StartAsync(); try { } finally { await busHandle.StopAsync(); } // })) // { // var queueAddress = new Uri(hostAddress, "input_queue"); // ISendEndpoint endpoint = bus.GetSendEndpoint(queueAddress); // // await endpoint.Send(new A()); // } }
public async Task StartAsync() { _busControl = _busFactory.Create(); await _busControl.StartAsync(); }
public Task StartAsync(CancellationToken cancellationToken) { _log.LogInformation("Starting bus..."); return(_busControl.StartAsync(cancellationToken)); }
public async Task StartAsync(CancellationToken cancellationToken) { this.logger.LogInformation("Masstransit Esb started"); await busControl.StartAsync(cancellationToken); }
public async Task StartAsync(CancellationToken cancellationToken) { _logger.LogInformation(FiggleFonts.Standard.Render("Bus producer!")); await _bus.StartAsync(cancellationToken).ConfigureAwait(false); }
static void Main() { ConfigureLogger(); // MassTransit to use Log4Net Log4NetLogger.Use(); IBusControl busControl = CreateBus(); TaskUtil.Await(() => busControl.StartAsync()); string validateQueueName = ConfigurationManager.AppSettings["ValidateActivityQueue"]; Uri validateAddress = _host.GetSendAddress(validateQueueName); string retrieveQueueName = ConfigurationManager.AppSettings["RetrieveActivityQueue"]; Uri retrieveAddress = _host.GetSendAddress(retrieveQueueName); try { for (;;) { Console.Write("Enter an address (quit exits): "); string requestAddress = Console.ReadLine(); if (requestAddress == "quit") { break; } if (string.IsNullOrEmpty(requestAddress)) { requestAddress = "http://www.microsoft.com/index.html"; } int limit = 1; if (requestAddress.All(x => char.IsDigit(x) || char.IsPunctuation(x))) { string[] values = requestAddress.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); requestAddress = values[0]; if (values.Length > 1) { limit = int.Parse(values[1]); Console.WriteLine("Sending {0}", limit); } } switch (requestAddress) { case "0": requestAddress = "http://www.microsoft.com/index.html"; break; case "1": requestAddress = "http://i.imgur.com/Iroma7d.png"; break; case "2": requestAddress = "http://i.imgur.com/NK8eZUe.jpg"; break; } Uri requestUri; try { requestUri = new Uri(requestAddress); } catch (UriFormatException) { Console.WriteLine("The URL entered is invalid: " + requestAddress); continue; } IEnumerable <Task> tasks = Enumerable.Range(0, limit).Select(x => Task.Run(async() => { var builder = new RoutingSlipBuilder(NewId.NextGuid()); builder.AddActivity("Validate", validateAddress); builder.AddActivity("Retrieve", retrieveAddress); builder.SetVariables(new { RequestId = NewId.NextGuid(), Address = requestUri, }); RoutingSlip routingSlip = builder.Build(); await busControl.Publish <RoutingSlipCreated>(new { TrackingNumber = routingSlip.TrackingNumber, Timestamp = routingSlip.CreateTimestamp, }); await busControl.Execute(routingSlip); })); Task.WaitAll(tasks.ToArray()); } } catch (Exception ex) { Console.WriteLine("Exception!!! OMG!!! {0}", ex); Console.ReadLine(); } finally { busControl.Stop(); } }
public Task <BusHandle> StartAsync(CancellationToken cancellationToken = default) { return(_busControl.StartAsync(cancellationToken)); }
public override async Task StartAsync(CancellationToken cancellationToken) { await base.StartAsync(cancellationToken); await bus.StartAsync(cancellationToken); }
public async Task StartAsync(CancellationToken cancellationToken) { var handle = await _bus.StartAsync(cancellationToken); }
public Task StartAsync(CancellationToken cancellationToken) { return(bus.StartAsync(cancellationToken)); }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { await _bus.StartAsync(stoppingToken); _logger.LogInformation($"Order Service started at: {DateTimeOffset.Now}"); }
public bool Start(HostControl hostControl) { Console.WriteLine("Creating bus..."); _busControl = MassTransit.Bus.Factory.CreateUsingRabbitMq(x => { IRabbitMqHost host = x.Host(new Uri(/*rabbitMQ server*/), h => { /*credentials*/ }); x.UseInMemoryScheduler(); x.UseMessageScheduler(new Uri(RabbitMqServerAddress)); x.ReceiveEndpoint(host, "validation_needed", e => { e.PrefetchCount = 1; e.Durable = true; //again this is how the consumer is registered e.Consumer <RequestConsumer>(); }); }); Console.WriteLine("Starting bus..."); try { _busHandle = MassTransit.Util.TaskUtil.Await <BusHandle>(() => _busControl.StartAsync()); _scheduler.JobFactory = new MassTransitJobFactory(_busControl); _scheduler.Start(); } catch (Exception) { _scheduler.Shutdown(); throw; } return(true); }
public async Task StartAsync(CancellationToken cancellationToken) { // 왜 ConfigureAwait(false) 가 필요할까. await _bus.StartAsync(cancellationToken).ConfigureAwait(false); }
public async Task StartAsync(CancellationToken cancellationToken) { await _busControl.StartAsync(cancellationToken); }
public async Task StartAsync(CancellationToken cancellationToken) { //start the bus await busControl.StartAsync(cancellationToken); }
public Task StartAsync(CancellationToken cancellationToken) { return(_busControl.StartAsync(cancellationToken)); }
public async Task SetUp() { await _busControl.StartAsync(); }
/// <summary> /// Start hosted service. /// </summary> /// <param name="cancellationToken">Cancellation token.</param> public Task StartAsync(CancellationToken cancellationToken) => _busControl.StartAsync(cancellationToken);
public async Task StartBus() { _busHandle = await _bus.StartAsync(); await _busHandle.Ready; }
public async Task SetupAzureServiceBusTestFixture() { _bus = CreateBus(); _bus.ConnectReceiveEndpointObserver(new ReceiveEndpointObserver()); _busHandle = await _bus.StartAsync(); try { _busSendEndpoint = await _bus.GetSendEndpoint(_bus.Address); _busSendEndpoint.ConnectSendObserver(_sendObserver); _inputQueueSendEndpoint = await _bus.GetSendEndpoint(_inputQueueAddress); _inputQueueSendEndpoint.ConnectSendObserver(_sendObserver); } catch (Exception) { try { using (var tokenSource = new CancellationTokenSource(TestTimeout)) { await _bus.StopAsync(tokenSource.Token); } } finally { _busHandle = null; _bus = null; } throw; } }
public Task StartAsync(CancellationToken cancellationToken) { _logger.LogInformation($"Starting the ServiceBus..."); return(_busControl.StartAsync(cancellationToken)); }