Share via


If you are using SQL Server Notification Services 2.0, you can get "Error 4085: The number of WaitHandles must be less than or equal to 64."

If you are using SQL Server Notification Services 2.0 and you are using a complex NS application with many notification classes inside a single NS instance, you may get 4085 generator errors..

Error 4085: The number of WaitHandles must be less than or equal to 64.

The error that you will see in Application Event Log
Event Type: Error
Event Source: NotificationServices
Event Category: None
Event ID: 4085
Date: 8/1/2007
Time: 5:27:15 PM
User: N/A
Computer: DBSW273
Description:
<NotificationServicesEvent>
<Description>
An error occurred while firing a rule.
</Description>
<Context>
<EventParameters>
<ApplicationName>CEMS</ApplicationName>
<QuantumId>72784</QuantumId>
</EventParameters>

</Context>
<Description>
The number of WaitHandles must be less than or equal to 64.
</Description>
<Instance>CEMSv1Instance</Instance>
<ApplicationName>CEMS</ApplicationName>
<Component>Generator</Component>
<Thread>5</Thread>
</NotificationServicesEvent>

 

This seems to be one of the limitations of NS2.0, resolved in SQL Server Notification Services 2005 (i.e. NS 9.0).

The way to make this work is to remember these three rules in mind:

1. Number of subscription classes + Number of event class <= 50
2. No of rule firings per quantum <= 50
3. Number of rule firings per quantum = Number of event chronicle rules + No of event subscription rules + Number of  times subscription rules

So, it will be advisable to bifurcate your NS applications into two separate applicaton with fewer notification clases in each one.

It is also suggested to make the ThreadPoolSize setting to 0. If we set this to zero, NS dynamically set thread pool size for generator.
So, the Application.ADF file's Generator section looks like this:
 <!-- Generator Current System -->
 <Generator>
  <SystemName>%_NSSystem_%</SystemName>
  <ThreadPoolSize>0</ThreadPoolSize>
 </Generator>

After this, stop NS application, run nscontrol upgrade, then restart everything.