public AzureCommandBus CreateCommandBus() { var commandQueue = _appSettings.GetAppSetting("CommandBus.QueueName"); var commandConnection = _appSettings.GetAppSetting("CommandBus.ConnectionString"); var cmd= new AzureCommandBus(commandConnection, commandQueue); return cmd; }
private static void RegisterBusComponents(IUnityContainer container) { var commandBus = new AzureCommandBus( new TopicSender( AzureConstants.SuitTopic, AzureConstants.TokenIssuer, AzureConstants.TokenAccessKey, AzureConstants.ServiceUriScheme, AzureConstants.ServiceNamespace, AzureConstants.ServicePath)); container.RegisterInstance <ICommandBus>(commandBus); }
public static void Main(string[] args) { IsRunning = true; Console.WriteLine("Started Customer Commands Worker"); var connectionString = "Endpoint=sb://sb-poc-assad.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=aFc9QxcotbKor/RJTt/nXZKuFGKbz1K1J30ZhmglvXM="; var commandQueueName = "customer-commands"; var serviceCollection = new ServiceCollection(); serviceCollection.AddSingleton <ICustomerRepository, CustomerSqlRepository>(); serviceCollection.AddSingleton <IBrandRepository, BrandRestApiRepository>(); serviceCollection.AddSingleton <IEventBus>(new AzureEventBus(connectionString)); serviceCollection.AddSingleton(new HttpClient()); serviceCollection.AddMessagingDependencies("CustomerServiceApp.Domain"); _dispatcher = new CommandDispatcher(serviceCollection.BuildServiceProvider()); _bus = new AzureCommandBus(connectionString, commandQueueName); RegisterOnMessageHandlerAndReceiveMessages(); while (IsRunning) { try { Thread.Sleep(1000); } catch (Exception ex) { Console.WriteLine("Error in Customer Worker", ex); throw; } } Console.WriteLine("Stopping Service"); Console.ReadLine(); }