protected override async Task RunAsync(CancellationToken cancellationToken) { var initialised = false; try { logger.LogDebug("Starting the Earning Events service."); jobContextManager = lifetimeScope.Resolve <IJobContextManager <JobContextMessage> >(); jobContextManager.OpenAsync(cancellationToken); initialised = true; logger.LogInfo("Started the Earning Events service."); await Task.Delay(Timeout.Infinite, cancellationToken); } catch (Exception exception) when(!(exception is TaskCanceledException)) { // Ignore, as an exception is only really thrown on cancellation of the token. logger.LogError($"Reference Data Stateless Service Exception. Error: {exception}.", exception); } finally { if (initialised) { logger.LogInfo("Earning Events Stateless Service End"); await jobContextManager.CloseAsync(); } } }
public Stateless(StatelessServiceContext context, IJobContextManager <JobContextMessage> jobContextManager) : base(context) { _jobContextManager = jobContextManager; }
public JobContextManagerService(IPaymentLogger logger, IJobContextManager <JobContextMessage> jobContextManager) { this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.jobContextManager = jobContextManager ?? throw new ArgumentNullException(nameof(jobContextManager)); }