All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.socialmetrix.mail.RateLimitedMailSender Maven / Gradle / Ivy

The newest version!
package com.socialmetrix.mail;

import com.google.common.util.concurrent.RateLimiter;

public class RateLimitedMailSender implements MailSender {

	private RateLimiter rateLimiter;
	private MailSender mailSender;

	public RateLimitedMailSender(double mailPerSecond, MailSender mailSender) {
		this.rateLimiter = RateLimiter.create(mailPerSecond);
		this.mailSender = mailSender;
	}

	@Override
	public void send(Mail mail) {
		this.rateLimiter.acquire();
		this.mailSender.send(mail);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy