Increasing Worker Threads and Duplicate Emails

3 года назад
I've increased the App Pool worker threads to help the system cope as it was crashing a lot.

Now my client is complaining of duplicate emails for everything.

Would setting the Maximum Worker Processes to 10, cause duplicate emails to go out?
The system records the email once in the Message Queue, but sometimes the client gets 4 duplicates, sometimes 5
3 года назад
Ok so multiple instances of the Task Scheduler was creating duplicate emails.

I've used the solution posted here > https://www.nopcommerce.com/boards/t/33278/taskmanager-needs-to-be-reworked.aspx

Have modified it a bit as it was crashing IIS.

  bool createdNew;
                    MutexSecurity mutexSecurity = new MutexSecurity();
                    mutexSecurity.AddAccessRule(new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null),
                                                                    MutexRights.Synchronize | MutexRights.Modify, AccessControlType.Allow));

                    //does not exist
                    using (var mutex = new Mutex(false, mutexId, out createdNew, mutexSecurity))
                    {
                        var hasHandle = false;
                        try
                        {
                            try
                            {
                                hasHandle = mutex.WaitOne(1000, false);
                                if (hasHandle == false) return;
                            }
                            catch (AbandonedMutexException)
                            {
                                hasHandle = true;
                            }

                            #region do work

                            this._timer.Change(-1, -1);
                            this.Run();

                            if (this.RunOnlyOnce)
                                this.Dispose();
                            else
                                this._timer.Change(this.Interval, this.Interval);


                            #endregion
                        }
                        finally
                        {
                            if (hasHandle)
                            {
                                if (mutex != null)
                                {
                                    mutex.ReleaseMutex();
                                    mutex.Dispose();
                                }
                            }
                        }
                    }
один месяц назад
Orion wrote:
Ok so multiple instances of the Task Scheduler was creating duplicate emails.

I've used the solution posted here > https://www.nopcommerce.com/boards/t/33278/taskmanager-needs-to-be-reworked.aspx

Have modified it a bit as it was crashing IIS.

  bool createdNew;
                    MutexSecurity mutexSecurity = new MutexSecurity();
                    mutexSecurity.AddAccessRule(new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null),
                                                                    MutexRights.Synchronize | MutexRights.Modify, AccessControlType.Allow));

                    //does not exist
                    using (var mutex = new Mutex(false, mutexId, out createdNew, mutexSecurity))
                    {
                        var hasHandle = false;
                        try
                        {
                            try
                            {
                                hasHandle = mutex.WaitOne(1000, false);
                                if (hasHandle == false) return;
                            }
                            catch (AbandonedMutexException)
                            {
                                hasHandle = true;
                            }

                            #region do work

                            this._timer.Change(-1, -1);
                            this.Run();

                            if (this.RunOnlyOnce)
                                this.Dispose();
                            else
                                this._timer.Change(this.Interval, this.Interval);


                            #endregion
                        }
                        finally
                        {
                            if (hasHandle)
                            {
                                if (mutex != null)
                                {
                                    mutex.ReleaseMutex();
                                    mutex.Dispose();
                                }
                            }
                        }
                    }


I know this was a good few years ago now, but you wouldn't happen to have a solution for 4.30 do you?

.net core 3.1 new mutex doesn't allow 4 arguments, which means I can't pass through mutexSecurity?

Thanks,
Craig