Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MailKit Dependency Injection With Quartz #31

Closed
faisalbwn opened this issue Aug 24, 2023 · 6 comments
Closed

MailKit Dependency Injection With Quartz #31

faisalbwn opened this issue Aug 24, 2023 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@faisalbwn
Copy link

Dear Daniel,

I am injecting the MailKitSimplifiedEmailReceiver in QuartzHostedService and using it in Quartz job, but due to following error Quartz job is not firing again, also the log is not being written:

warn: MailKitSimplified.Receiver.Services.LogFileWriterQueue[0]
Log queue cancelled while logs are still being written.
fail: Quartz.Core.QuartzSchedulerThread[0]
Runtime error occurred in main trigger firing loop.
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'LoggerFactory'.
at Microsoft.Extensions.Logging.LoggerFactory.CreateLogger(String categoryName)
at Quartz.Simpl.MicrosoftLoggingProvider.GetLogger(String name)
at Quartz.Logging.LogProvider.GetLogger(String name)
at Quartz.Logging.LogProvider.GetLogger(Type type, String fallbackTypeName)
at Quartz.Core.JobRunShell..ctor(IScheduler scheduler, TriggerFiredBundle bundle)
at Quartz.Impl.StdJobRunShellFactory.CreateJobRunShell(TriggerFiredBundle bndle)
at Quartz.Core.QuartzSchedulerThread.Run()

@danzuep danzuep self-assigned this Aug 25, 2023
@danzuep
Copy link
Owner

danzuep commented Aug 25, 2023

I thought this might become an issue, but no one had complained about it so I wasn't sure. Here's the reason from Microsoft: "Services resolved from the container should never be disposed by the developer." https://learn.microsoft.com/en-us/dotnet/core/extensions/dependency-injection-guidelines#disposal-of-services

@danzuep
Copy link
Owner

danzuep commented Aug 25, 2023

Please check the latest preview release.

@faisalbwn
Copy link
Author

Thanks Daniel.
I updated to pre-release and it fixed the issue. But there is one more issue related to it, I am giving the "ProtocolLog" path in appSetttings.json but it is not creating the log files for both sender and receiver.
Can you please guide for sender and receiver logging.

@danzuep
Copy link
Owner

danzuep commented Aug 27, 2023

I'd written my own file writer that was set as follows: "ProtocolLogger:FileWriter:FilePath": "Logs\\ImapClient.txt"
I've fixed it in the latest pre-release so you can use the method in the documentation again: "ProtocolLog": "Logs\\ImapClient.txt"

Please check it works and close this issue if it does.

@faisalbwn
Copy link
Author

Thanks for helping out Daniel. Closing the ticket and looking forward for stable release.

@danzuep
Copy link
Owner

danzuep commented Aug 27, 2023

Jeffrey Stedfast himself (of MailKit fame) replied to our query with some suggestions on how to improve performance by using UniqueIdSet with UniqueIdRange, so please try out the latest release.

@danzuep danzuep added the bug Something isn't working label Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants