public ReceiveEndpointSettings(IServiceBusEndpointConfiguration endpointConfiguration, string queueName, QueueConfigurator queueConfigurator) : base(endpointConfiguration, queueConfigurator) { _queueConfigurator = queueConfigurator; Name = queueName; }
public void Setup(IMessagingConfiguration config, bool deleteDb = true) { if (config == null) { config = TestMessagingConfiguration.Create(); } var containerBuilder = new ContainerBuilder(); var serviceProvider = new ServiceCollection(); var configurator = new QueueConfigurator(serviceProvider, GetRegistrator()); configurator .SetConfigurationProvider(config) .SetTopicProvider <TestTopicNameProvider>() .RegisterHandler <TestHandler>() .RegisterHandler <SlightlyDifferentTestHandler>() .RegisterHandler <AlwaysErrorHandler>() .RegisterHandler <ResendHandler>() .RegisterHandler <TransactionResendHandler>() .RegisterHandler <TimeConsumingHandler>(); serviceProvider.AddSingleton(configurator); serviceProvider.AddSingleton <IInstanceResolver, ServiceProviderResolver>(); containerBuilder.Populate(serviceProvider); var container = containerBuilder.Build(); Resolver = container.Resolve <IInstanceResolver>(); Builder = configurator.Build(Resolver); if (deleteDb) { ClearDb(); } }
static void Main(string[] args) { string route = "listener2"; if (args.Any()) { route = args[0]; } var autofacRegistrator = new AutofacRegistrator(); var configurator = new QueueConfigurator(autofacRegistrator, new MessagingDependencyRegistrator()) .RegisterHandler <DefaultHandler>() .RegisterHandler <AnotherDefaultHandler>(); var builder = configurator.Build(autofacRegistrator.CreateResolver()); var subscriber = builder.GetSubscriber(); subscriber.Subscribe <DefaultHandler, DomainMessage>(); subscriber.Subscribe <AnotherDefaultHandler, AnotherDomainMessage>(); var mongoMessageListener = builder.GetListener(); mongoMessageListener.Start(route, CancellationToken.None).Wait(); Console.WriteLine($"started listener {route}"); Console.ReadLine(); }
public static IEventDataReceiver CreateEventDataReceiver(this IBusFactorySelector selector, IBinder binder, Action <IWebJobReceiverConfigurator> configure) { if (binder == null) { throw new ArgumentNullException(nameof(binder)); } if (configure == null) { throw new ArgumentNullException(nameof(configure)); } var topologyConfiguration = new ServiceBusTopologyConfiguration(AzureBusFactory.MessageTopology); var busConfiguration = new ServiceBusBusConfiguration(topologyConfiguration); var queueConfigurator = new QueueConfigurator("no-host-configured") { AutoDeleteOnIdle = Defaults.TemporaryAutoDeleteOnIdle, }; var settings = new ReceiveEndpointSettings("no-host-configured", queueConfigurator); var busEndpointConfiguration = busConfiguration.CreateReceiveEndpointConfiguration(settings, busConfiguration); var configurator = new WebJobEventDataReceiverSpecification(binder, busEndpointConfiguration); configure(configurator); return(configurator.Build()); }
public ReceiveEndpointSettings(string queueName, QueueConfigurator queueConfigurator) : base(queueConfigurator) { _queueConfigurator = queueConfigurator; Name = queueName; }
public Uri GetDestinationAddress(string queueName, Action <IQueueConfigurator> configure = null) { var configurator = new QueueConfigurator(queueName); configure?.Invoke(configurator); return(configurator.GetQueueAddress(_hostAddress)); }
Uri GetQueueAddress(QueueConfigurator configurator, Uri hostAddress, string suffix) { var queueName = configurator.QueueName + suffix; var sendSettings = new RabbitMqSendSettings(queueName, ExchangeTypeSelector.DefaultExchangeType, configurator.Durable, configurator.AutoDelete); sendSettings.BindToQueue(queueName); return(sendSettings.GetSendAddress(hostAddress)); }
public ServiceBusBusFactoryConfigurator(IServiceBusBusConfiguration busConfiguration, IServiceBusEndpointConfiguration busEndpointConfiguration) : base(busConfiguration, busEndpointConfiguration) { _configuration = busConfiguration; _busEndpointConfiguration = busEndpointConfiguration; _queueConfigurator = new QueueConfigurator("no-host-configured") { AutoDeleteOnIdle = Defaults.TemporaryAutoDeleteOnIdle, }; _settings = new ReceiveEndpointSettings("no-host-configured", _queueConfigurator); }
public ServiceBusBusFactoryConfigurator(IServiceBusBusConfiguration busConfiguration) : base(busConfiguration) { _busConfiguration = busConfiguration; _hostConfiguration = busConfiguration.HostConfiguration; var queueName = _busConfiguration.Topology.Consume.CreateTemporaryQueueName("bus"); _queueConfigurator = new QueueConfigurator(queueName) { AutoDeleteOnIdle = Defaults.TemporaryAutoDeleteOnIdle }; _settings = new ReceiveEndpointSettings(queueName, _queueConfigurator); }
public Uri GetDestinationAddress(Type messageType, Action <IQueueConfigurator> configure = null) { var queueName = _messageNameFormatter.GetMessageName(messageType).ToString(); var configurator = new QueueConfigurator(queueName); if (TypeMetadataCache.IsTemporaryMessageType(messageType)) { configurator.AutoDeleteOnIdle = Defaults.TemporaryAutoDeleteOnIdle; } configure?.Invoke(configurator); return(configurator.GetQueueAddress(_hostAddress)); }
public void Setup() { var autofacRegistrator = new AutofacRegistrator(); var configurator = new QueueConfigurator(autofacRegistrator, GetRegistrtor()); configurator .SetConfigurationProvider(TestMessagingConfiguration.Create()) .SetTopicProvider <TestTopicNameProvider>() .RegisterHandler <TestHandler>() .RegisterHandler <SlightlyDifferentTestHandler>() .RegisterHandler <ResendHandler>() .RegisterHandler <TimeConsumingHandler>(); Resolver = autofacRegistrator.CreateResolver(); Builder = configurator.Build(Resolver); ClearDb(); }
public ServiceBusBusFactoryConfigurator(IServiceBusBusConfiguration busConfiguration, IServiceBusEndpointConfiguration busEndpointConfiguration) : base(busConfiguration, busEndpointConfiguration) { _configuration = busConfiguration; _busEndpointConfiguration = busEndpointConfiguration; var busQueueName = _configuration.Topology.Consume.CreateTemporaryQueueName("bus"); _queueConfigurator = new QueueConfigurator(busQueueName) { AutoDeleteOnIdle = Defaults.TemporaryAutoDeleteOnIdle, EnableExpress = true }; _settings = new ReceiveEndpointSettings(busQueueName, _queueConfigurator); }
public ServiceBusBusFactoryConfigurator(IServiceBusEndpointConfiguration configuration) : base(configuration) { _configuration = configuration; _hosts = new BusHostCollection <ServiceBusHost>(); _sendTransportProvider = new ServiceBusSendTransportProvider(_hosts); var queueName = ((IServiceBusHost)null).GetTemporaryQueueName("bus"); _queueConfigurator = new QueueConfigurator(queueName) { AutoDeleteOnIdle = TimeSpan.FromMinutes(5), EnableExpress = true }; _settings = new ReceiveEndpointSettings(_queueConfigurator); }
static async Task DoStuff() { var autofacRegistrator = new AutofacRegistrator(); var configurator = new QueueConfigurator(autofacRegistrator, new MessagingDependencyRegistrator()); var builder = configurator.Build(autofacRegistrator.CreateResolver()); var publisher = builder.GetPublisher(); while (true) { try { var rnd = new Random(DateTime.Now.Millisecond); var id = rnd.Next(); var guid = Guid.NewGuid().ToString(); if (id % 2 == 0) { if (id % 4 == 0) { var message = new DomainMessage(guid, "exception"); await publisher.PublishAsync(message); } else { var message = new DomainMessage(guid, rnd.Next().ToString()); await publisher.PublishAsync(message); } } else { var message = new AnotherDomainMessage(guid, rnd.Next().ToString(), "waddap indeed"); await publisher.PublishAsync(message); } } catch (Exception e) { Console.WriteLine(e.ToString()); await Task.Delay(500); } } }
public ReceiveEndpointSettings(QueueConfigurator queueConfigurator) { _queueConfigurator = queueConfigurator; }
public Uri GetDeadLetterAddress(QueueConfigurator configurator, Uri hostAddress) { return(GetQueueAddress(configurator, hostAddress, "_skipped")); }
public Uri GetErrorAddress(QueueConfigurator configurator, Uri hostAddress) { return(GetQueueAddress(configurator, hostAddress, "_error")); }