Hi,
I will first explain the situation. Our software is running in a cloud server farm. We need to send e-mails to our clients with some kind of alerts. We decided that is better to send only 1 e-mail per 30 seconds, to avoid going to SPAM filters or blacklists.
public void SendMail()
{
System.Threading.Thread.Sleep(30000);
//really send email
}
public void Check()
{
for (int i = 0; i < 10; i++)
{
BackgroundJob.Enqueue(() =>
SendMail()
);
}
}
But, as Hangfire uses all possible servers to run threads and sometimes we have like 5 servers online, we could send 5 e-mails at same time. All servers run the same code, and I am unable to detect who server is who in code.
So, is it possible to categorize all my SendMail functions, in order to specify that them must follow only one line, maybe in one of the servers? I preffer to not specify which server, so it goes offline, another could continue the queue.
Thanks a lot.