-
-
Notifications
You must be signed in to change notification settings - Fork 267
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
Bug: batch-module gives error when there is a custom mailer #375
Comments
So I understand what you're trying to do, but that's not how the CustomMailer was designed. The point was to be able to replace the sending engine with your own, not tweak mails coming through and then still use the initial (internal) sending engine (using TransportRunner). So what's happening here is that you have both a CustomMailer, but then also the batch-module on the classpath. Currently, Simple Java Mail skips the cluster when a custom mailer is present. Your method would work find if you removed the batch-module. The reasoning here is that the batch module prevents the JVM from shutting down (because you need to stop the clusters/connection pool manually) and that doesn't make sense if you provide your own custom mailer implementation. One thing I am considering is that if both CustomMailer and batch-module are available, Simple Java Mail will throw a more descriptive error rather than some vague statement about a connection pool. I'm not sure otherwise how to elegantly define an API on the builder that flags the system to still use batch-module even though there is a custom mailer. |
Thanks for the reply. It confirms what I inferred about CustomMailer's intent.
If a user has a CustomMailer that does not rely on the Does this logic make sense? |
It does and I will give this some more thought... |
@bbottema . So what do you think? I may even try and create a PR for this task if that's the direction you'd like to proceed. |
…iler (necessity implied by inclusion of batch-module)
I've released a fix for this in 7.0.1. Enjoy! |
This was fast :) Thanks! What do you think about backporting it to 6.x? In Bootique I would like to support both javax and jakarta APIs for some time |
…iler (necessity implied by inclusion of batch-module)
Done. It's in 6.7.6 |
Much appreciated!! |
I am using SJM 6.x via Bootique integration. One feature that I need myself and is being requested by other Bootique users is the ability to override recipients of a message for testing purposes. Something like this:
This is ideal for QA, as it preserves the real To, Cc, Bcc, but delivers to a designated test mailbox. I tried implementing it as a
CustomMailer
in Bootique. Unfortunately it is not easy to do it, as the presence ofCustomMailer
prevents SJM stack from configuring itself properly. So a call like this results in an NPE:Wanted to ask for an expert opinion on a better way to do a custom dispatch via TransportRunner. Or maybe there's interest to make recipient override feature (which has been quite handy with a different mail stack) a part of SJM?
The text was updated successfully, but these errors were encountered: