-
-
Notifications
You must be signed in to change notification settings - Fork 273
Open
Labels
Description
I am trying to configure different corePoolSize for 2 Mailer instances, but so far without success. As i understand from documentation, all i need is to define different clusterKey for each Mailer. But it doesn`t work as I expect. I also use batch-module.
- new SmtpConnectionPoolClustered beeing created here just for 1st Mailer. For 2nd I am getting warning "Global SMTP Connection pool is already configured with pool defaults ...".
Lines 84 to 91 in 375bbd6
private void ensureClusterInitialized(@NotNull OperationalConfig operationalConfig) { if (smtpConnectionPool == null) { LOGGER.warn("Starting SMTP connection pool cluster: JVM won't shutdown until the pool is manually closed with mailer.shutdownConnectionPool() (for each mailer in the cluster)"); smtpConnectionPool = new SmtpConnectionPoolClustered(configureSmtpClusterConfig(operationalConfig)); } else if (compareClusterConfig(operationalConfig, smtpConnectionPool.getClusterConfig())) { LOGGER.warn("Global SMTP Connection pool is already configured with pool defaults from the first Mailer instance, ignoring relevant properties from {}", operationalConfig); } } - So there is just one instance of ResourceClusters created with clusterConfig (including corePoolSize) from 1st MailerBuilder cofig. Then it`s beeing reused for 2nd cluster as well.
https://github.com/bbottema/clustered-object-pool/blob/5857ced611c5be3489cd3cb763bfce8421aab9d9/src/main/java/org/bbottema/clusteredobjectpool/core/ResourceClusters.java#L55
My config:
@Bean(name = FIRST_SERVER_HOST)
public Mailer mailerFirst() {
return MailerBuilder
.withSMTPServer(FIRST_SERVER_HOST, FIRST_SERVER_PORT)
.async()
.withThreadPoolSize(20)
.withConnectionPoolCoreSize(1)
.withClusterKey(UUID.randomUUID())
.buildMailer();
}
@Bean(name = SECOND_SERVER_HOST)
public Mailer mailerSecond() {
return MailerBuilder
.withSMTPServer(SECOND_SERVER_HOST, SECOND_SERVER_PORT)
.async()
.withThreadPoolSize(20)
.withConnectionPoolCoreSize(0)
.withClusterKey(UUID.randomUUID())
.buildMailer();
}