Beispiel #1
0
        public void CreateBus(IServiceCollectionBusConfigurator busConfigurator, IStartupBusConfigurator configurator)
        {
            if (!configurator.HasSchedulerEndpoint)
            {
                busConfigurator.AddServiceBusMessageScheduler();
            }

            busConfigurator.UsingAzureServiceBus((context, cfg) =>
            {
                var options = context.GetRequiredService <IOptions <ServiceBusOptions> >().Value;
                if (string.IsNullOrWhiteSpace(options.ConnectionString))
                {
                    throw new ConfigurationException("The Azure Service Bus ConnectionString must not be empty.");
                }

                cfg.Host(options.ConnectionString);

                if (!configurator.TryConfigureQuartz(cfg))
                {
                    Log.Information("Configuring Azure Service Bus Message Scheduler (enqueue time)");
                    cfg.UseServiceBusMessageScheduler();
                }

                configurator.ConfigureBus(cfg, context);
            });
        }
        public void CreateBus(IServiceCollectionBusConfigurator busConfigurator, IStartupBusConfigurator configurator)
        {
            if (!configurator.HasSchedulerEndpoint)
            {
                busConfigurator.AddAmazonSqsMessageScheduler();
            }

            busConfigurator.UsingAmazonSqs((context, cfg) =>
            {
                var options = context.GetRequiredService <IOptions <AmazonSqsOptions> >().Value;
                if (string.IsNullOrWhiteSpace(options.Region))
                {
                    cfg.Host(new UriBuilder("amazonsqs://docker.localhost:4576")
                    {
                        Path = options.Scope
                    }.Uri, h =>
                    {
                        h.AccessKey("admin");
                        h.SecretKey("admin");
                        h.Config(new AmazonSimpleNotificationServiceConfig {
                            ServiceURL = "http://docker.localhost:4575"
                        });
                        h.Config(new AmazonSQSConfig {
                            ServiceURL = "http://docker.localhost:4576"
                        });
                    });
                }
                else
                {
                    cfg.Host(new UriBuilder("amazonsqs://host")
                    {
                        Host = options.Region,
                        Path = options.Scope
                    }.Uri, h =>
                    {
                        h.AccessKey(options.AccessKey);
                        h.SecretKey(options.SecretKey);
                    });
                }

                if (!configurator.TryConfigureQuartz(cfg))
                {
                    Log.Information("Configuring Amazon SQS Message Scheduler");
                    cfg.UseAmazonSqsMessageScheduler();
                }

                configurator.ConfigureBus(cfg, context);
            });
        }
Beispiel #3
0
        public void CreateBus(IServiceCollectionBusConfigurator busConfigurator, IStartupBusConfigurator configurator)
        {
            if (!configurator.HasSchedulerEndpoint)
            {
                busConfigurator.AddRabbitMqMessageScheduler();
            }

            busConfigurator.UsingRabbitMq((context, cfg) =>
            {
                var options    = context.GetRequiredService <IOptions <RabbitMqOptions> >().Value;
                var sslOptions = context.GetRequiredService <IOptions <RabbitMqSslOptions> >().Value;

                cfg.Host(options.Host, options.Port, options.VHost, h =>
                {
                    h.Username(options.User);
                    h.Password(options.Pass);

                    if (options.UseSsl)
                    {
                        h.UseSsl(s =>
                        {
                            s.ServerName            = sslOptions.ServerName;
                            s.CertificatePath       = sslOptions.CertPath;
                            s.CertificatePassphrase = sslOptions.CertPassphrase;
                            s.UseCertificateAsAuthenticationIdentity = sslOptions.CertIdentity;

                            if (sslOptions.Trust)
                            {
                                s.AllowPolicyErrors(SslPolicyErrors.RemoteCertificateNameMismatch | SslPolicyErrors.RemoteCertificateChainErrors
                                                    | SslPolicyErrors.RemoteCertificateNotAvailable);
                            }
                        });
                    }
                });

                if (!configurator.TryConfigureQuartz(cfg))
                {
                    Log.Information("Configuring RabbitMQ Message Scheduler (delayed exchange)");
                    cfg.UseDelayedExchangeMessageScheduler();
                }

                configurator.ConfigureBus(cfg, context);
            });
        }
        public void CreateBus(IServiceCollectionBusConfigurator busConfigurator, IStartupBusConfigurator configurator)
        {
            if (!configurator.HasSchedulerEndpoint)
            {
                busConfigurator.AddActiveMqMessageScheduler();
            }

            busConfigurator.UsingActiveMq((context, cfg) =>
            {
                var options = context.GetRequiredService <IOptions <ActiveMqOptions> >().Value;

                cfg.Host(options.Host, options.Port, h =>
                {
                    if (!string.IsNullOrWhiteSpace(options.User))
                    {
                        h.Username(options.User);
                    }
                    if (!string.IsNullOrWhiteSpace(options.Pass))
                    {
                        h.Password(options.Pass);
                    }

                    if (options.UseSsl)
                    {
                        h.UseSsl();
                    }
                });

                if (!configurator.TryConfigureQuartz(cfg))
                {
                    Log.Information("Configuring ActiveMQ Message Scheduler");
                    cfg.UseActiveMqMessageScheduler();
                }

                configurator.ConfigureBus(cfg, context);
            });
        }