Open
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 ...".
- 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();
}