Repository navigation
Description
Context
org.simplejavamail:batch-module is a separately published artifact and depends only on core-module and smtp-connection-pool, but it currently has no supported standalone API.
Its usable types are under org.simplejavamail.internal... or org.simplejavamail.api.internal..., registerToCluster(...) requires the Mailer-wide OperationalConfig, and the module Javadoc explicitly says that it has no public API by itself.
This leaves a useful middle path between:
- direct low-level use of
smtp-connection-pool, where callers manually claim, release, invalidate, and shut down resources; - full Simple Java Mail
EmailBuilder/Mailerusage; and - the standard Jakarta Mail
smtppoolprovider proposed in smtp-connection-pool #10.
Goal
Expose a supported API for applications that create their own Jakarta Mail Session and MimeMessage objects but want batch-module's asynchronous execution, clustered connection pooling, safe transport lifecycle, and deterministic shutdown. This additive API targets Simple Java Mail 9.3.0, not 10.0.0.
The provider and batch-module APIs are parallel choices. The batch API must not wrap or recursively select the pooled Jakarta Mail provider.
Simple Java Mail itself remains a direct smtp-connection-pool integration because it needs clustering/sticky selection, the actual Session/Transport, receipt handling, precise failure behavior, and deterministic shutdown. It should reuse the shared upstream transport-lease contract, not route its Mailer through PooledTransport.
Proposed API direction
Add a public org.simplejavamail.batch facade centered on:
BatchTransportExecutor<K>and its builder;- dedicated global and per-cluster configuration;
- registration of Jakarta Mail Sessions under cluster keys;
- separate cluster-selected and session-sticky operations;
- a callback that receives the selected Session and Transport, releases automatically on success, and invalidates automatically on failure;
- optional asynchronous submission returning
CompletableFuture; and - explicit, deterministic lifecycle through
AutoCloseable.
Keep the raw upstream lease internal to this facade so callers cannot accidentally leak it. Keep the existing internal BatchModule reflection boundary as a compatibility adapter for the full Simple Java Mail Mailer integration. Both public and internal paths should delegate to one engine.
Acceptance criteria
- A consumer can compile and run using only
org.simplejavamail:batch-moduleand its transitive dependencies; the mainsimple-java-mailartifact is not required. - The documented consumer example imports no
org.simplejavamail.internal...ororg.simplejavamail.api.internal...types. - Public configuration covers core size, maximum size, claim timeout, expiry, load-balancing strategy, and per-cluster overrides without requiring
OperationalConfig. - Callers can register one or more Jakarta Mail Sessions under a cluster key.
- Public operations support both cluster-selected and session-sticky use and expose the actual selected Session alongside its Transport.
- The callback API releases after success and invalidates after failure without exposing or leaking a claimed lease.
- Public failures retain useful causes without exposing credentials or OAuth2 tokens.
- Fixed OAuth2 tokens and refresh-aware token suppliers are resolved from the actually selected registered Session at the physical connection or reconnection boundary.
- Default executors are module-owned, supplied executors remain caller-owned, and ownership is documented and tested.
-
close()/shutdown is idempotent, closes registered pools, waits according to documented semantics, and prevents new acquisitions. - Existing Mailer behavior remains compatible and delegates to the shared engine.
- The batch path never recursively selects
smtppoolor creates a pool over a provider-owned pool. - Public API compile, single-pool, multi-session cluster, sticky selection, failure invalidation, OAuth2, executor ownership, shutdown, and module-path tests are present.
- Generated Javadocs replace the current static “no public API” page.
- Java 8 compatibility and the
org.simplejavamail.batchautomatic module name are preserved. - Simple Java Mail release notes add a Supporting Libraries entry for the required upstream release.
Website
After the public API exists, add:
- source:
simplejavamail.org/src/pages/smtp-connection-pooling.hbs; - route:
/smtp-connection-pooling.html, as a child of/modules.html; - a complete Session/MimeMessage callback example and lifecycle guidance;
- links from the batch section in
modules.hbsand the existing batch/pooling sections inconfiguration.hbs; and - a comparison matrix covering no pool, Mailer + batch-module, standalone batch-module, direct smtp-connection-pool, Jakarta/Spring
smtppool, and Camel; and - an explicit one-pool-owner rule so batch/direct orchestration is never stacked over
smtppool.
Do not publish the direct-use guide before the public API exists. Validate with npm run check, npm run verifyLinks:internal, and npm run build.
Non-goals
- Implementing the Jakarta Mail
smtppoolprovider itself; that belongs to smtp-connection-pool Unicode in local part of email address fails #10. - Replacing or weakening the full Simple Java Mail
EmailBuilderandMailerAPIs. - Adding automatic retries, transparent failover, server quarantine, circuit breaking, or message construction.
- Making Spring JavaMailSender depend on this facade; Spring should use the standard provider path.
- Stacking the batch-owned pool over
smtppool.
Coordination
- Consume the compatible lease contract from smtp-connection-pool #10 through the JPMS-fixed 4.0.1 follow-up tracked in smtp-connection-pool #11.
- Update
modules/batch-module/pom.xmlonly after that upstream release is available. - Land website documentation in the separate
simple-java-mail/simplejavamail.orgrepository, then update the website submodule revision in this repository. - Assign a Simple Java Mail milestone only after its concrete release target is accepted.
Activity
[-]Expose the batch module as a supported API and document the SMTP pooling paths[/-][+]Expose batch-module as a supported standalone Jakarta Mail pooling API[/+]bbottema commentedon Aug 10, 2026
The upstream module-path chain is now complete and available from Maven Central:
generic-object-pool 2.4.2—org.bbottema.genericobjectpoolclustered-object-pool 4.0.3—org.bbottema.clusteredobjectpoolsmtp-connection-pool 4.0.1—org.simplejavamail.smtpconnectionpool(plus stable names for the optional Jakarta provider and Camel adapter)Requirements for the Simple Java Mail 9.3.0 work are:
SmtpTransportLease; it does not route its rich Mailer lifecycle through thesmtppoolPooledTransportfacade.batch-moduleAPI keeps the raw lease internal, exposes a safe callback around the selected JakartaSession/Transport, releases on success, and invalidates on broken or uncertain failure.Transportimplementation can be selected beneath the pool; aCustomMailerimplementation instead owns a separate lifecycle and must not be nested with the batch pool.No Angus change is required for #698. The released core/provider artifacts remain Java 8 compatible; the optional Camel adapter remains isolated at Java 17 / Camel 4.21.x.
[-]Expose batch-module as a supported standalone Jakarta Mail pooling API[/-][+]Expose batch-module as a supported standalone Jakarta Mail orchestration API[/+]bbottema commentedon Aug 11, 2026
Available in Simple Java Mail 9.3.0.
Add
org.simplejavamail:batch-module:9.3.0, then register a Jakarta Mail Session and run message work inside the callback:The facade also supports exact-Session callbacks,
CompletableFuturesubmission, per-cluster pool configuration, selected-Session OAuth2 resolution, injected executor ownership, and graceful or forced shutdown. It keepsSmtpTransportLeaseprivate, releases on success, invalidates on failure, and rejects recursive use oversmtppool.See the comparison and orchestration guide and the runnable BatchModuleDemo.
No Angus change was needed for this issue; #699 remains the separate transport initiative.
bbottema commentedon Sep 7, 2026
The waiting-claim recovery fix is now available in Simple Java Mail 9.3.4, through SMTP Connection Pool 4.0.2. Upgrade Simple Java Mail and any separately declared batch-module dependency to 9.3.4; the standalone batch API remains unchanged. Details: #724.
bbottema commentedon Sep 17, 2026
SMTP Connection Pool 4.2.0 is now available on Maven Central, using clustered-object-pool 4.1.1 and generic-object-pool 2.5.1.
The provider/Camel path gains optional creation-age expiration, and the upstream fix keeps creation-age and last-claim policies distinct even when their thresholds match. Details: SMTP #33 and PR #34.
Simple Java Mail and standalone batch-module still need a separate 9.x patch to expose this through their builders, properties, per-cluster settings, Spring and CLI support. They construct their own policies through the direct pool API, so a dependency update alone does not expose the new option. That follow-up will retain the direct integration and disabled-by-default behavior; it will not stack batch pooling over the Jakarta
smtppoolprovider.Creation age makes available transports eligible for background retirement; it does not interrupt active leases or impose a strict maximum lifetime. The 9.x integration is the next task and is not yet released.
bbottema commentedon Oct 12, 2026
Supporting-library follow-up: SMTP Connection Pool 4.4.0 is available, using Clustered Object Pool 4.3.0 and Generic Object Pool 2.6.0. Existing acquisition APIs and provider/Camel configuration remain compatible. The new direct-pool selection and observation hooks support the ongoing coordinated failover work in #755; no email retry behavior is added by the pool itself.
bbottema commentedon Nov 5, 2026
SMTP Connection Pool 4.4.1 is available. OAuth connections keep the selected Jakarta Mail provider's username resolution, so an SMTPS Session can retain a different unused SMTP username without selecting that account. Existing fixed-token and supplier configuration stays supported. The matching dependency update for the 10.0.0 development branch is tracked in #966.
bbottema commentedon Nov 5, 2026
SMTP Connection Pool 4.5.0 adds an optional token supplier on the existing per-Session
registerResourcePoolAPI. Existing registration/property callers remain supported. The matching unreleased SJM 10.0.0 integration is tracked in #967; it keeps the standalone facade's documented credential inputs while removing the additional property copy.