public void ConfigureServices(IServiceCollection services) { var configuration = Configuration; PulsarSettings options = configuration.GetSection("Pulsar").Get <PulsarSettings>(); services.AddSingleton(options); services.AddSignalR((o) => { o.EnableDetailedErrors = true; }); services.AddHostedService <Worker>(); }
public Worker(ILogger <Worker> logger, IHubContext <EchoHub> echo, PulsarSettings pulsarSettings) { _echo = echo; _logger = logger; var clientConfig = new PulsarClientConfigBuilder() .ServiceUrl(pulsarSettings.ServiceUrl) .ConnectionsPerBroker(1) .UseProxy(pulsarSettings.UseProxy) .OperationTimeout(pulsarSettings.OperationTimeout) .AllowTlsInsecureConnection(false) .ProxyServiceUrl(pulsarSettings.ProxyServiceUrl, ProxyProtocol.SNI) .Authentication(new AuthenticationDisabled()) .ClientConfigurationData; _topic = pulsarSettings.Topic; _pulsarSystem = PulsarSystem.GetInstance(clientConfig); _schema = AvroSchema.Of(typeof(Echo.Common.Echo)); _consumer = Consumer(pulsarSettings); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { PulsarSettings options = Configuration.GetSection("Pulsar").Get <PulsarSettings>(); services.AddSingleton(options); services.AddCors(options => options.AddPolicy("CorsPolicy", builder => { builder.AllowAnyHeader() .AllowAnyMethod() .SetIsOriginAllowed((host) => true) .AllowCredentials(); })); services.AddSingleton <IHostedService, HostService>(); services.AddControllersWithViews(); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); }
private IActorRef Consumer(PulsarSettings pulsarSettings) { var consumerListener = new DefaultConsumerEventListener(l => { }); var consumerConfig = new ConsumerConfigBuilder() .ConsumerName(pulsarSettings.Topic) .ForceTopicCreation(true) .SubscriptionName($"{pulsarSettings.Topic}-Subscription") .Topic(pulsarSettings.Topic) //.AckTimeout(10000) .AcknowledgmentGroupTime(0) .ConsumerEventListener(consumerListener) .SubscriptionType(CommandSubscribe.SubType.Exclusive) .Schema(_schema) .SetConsumptionType(ConsumptionType.Queue) .MessageListener(new DefaultMessageListener(null, null)) .StartMessageId(MessageIdFields.Earliest) .SubscriptionInitialPosition(SubscriptionInitialPosition.Earliest) .ConsumerConfigurationData; return(_pulsarSystem.PulsarConsumer(new CreateConsumer(_schema, consumerConfig)).Consumer); }
public PulsarConnector(PulsarSettings pulsarSettings, IWebHostEnvironment env) { _pulsarSettings = pulsarSettings; _contentRoot = env.ContentRootPath; }
public HostService(PulsarSettings pulsarSettings, IWebHostEnvironment env) { PulsarConnector = new PulsarConnector(pulsarSettings, env); }