Ah very nice! And you described it well, makes perfect sense.
MarkSW wrote:
> Joe, I just wanted to mention a design pattern that essentially works around
> the limitations you describe below, although at the cost of some complexity.
>
> We have the need of an NS application that will run "continuously" as long
> as there are rows in a queue table that need to be processed. We implmented
> this first with a Scheduled Event Provider. But after a while (in
> production, of course) the queue grew and the call to Run() exceeded the
> five-minute limit imposed by NS as part of using IScheuledEventProvider. So
> we hit upon this scheme, with assistance from MS posters on this board:
>
> Have Run() spawn a thread bound to a worker method that processes the queue,
> then have Run() return immediately. So, you never hit the five-minute limit,
> and you worker method just loops on the queue and returns (and dies) when it
> is drained.
>
> This is great, but not enough (at least this showed up in QA), because NS
> continues to call run on the Schedule period set in the ADF, which means
> concurrency problems if the last call in RunWorker() hasn't returned before
> the next call to ran spawns a new thread and new call to RunWorker(). So,
> the second essential part of this pattern is a semaphore that guards access
> to the call to spawn the RunWorker() thread, which is only released by
> RunWorker() when it's done and about to return (as the very last thing it
> does before returning). This we implemented just with Interlocked. So, not
> unsophisticated to understand, but actually all this is not a lot of code in
> .NET.
>
> This has been working great in production for about 6 months now. And it
> has the single great advantage of turning NS into a real-time "run until
> done" system if you have some outside queue your EventProvider must consume
> as the definition of your event.
>
>
> "Joe Webb" wrote:
>
>
>>Well, I would not go so far as to say that SQLNS is polling based.
>>
>>Here's what happens...Events are entered into the system in real-time
>>(or polled into the system depending on your event provider) and are
>>batched for efficiency. Consider the stock sample app as an example. You
>>could have several 1000's of events entering the system almost instantly
>>- say through a single XML document that contains every stock on the
>>NYSE. The file system watcher event provider will pick up the document
>>immediately. Rather than firing a notification immediately for every
>>stock, SQLNS batches these events and processes them as a single unit.
>>The generator component is fired periodically (at its quantum) and
>>matches the events to the subscriptions and produces notifications. The
>>notifications are batched in a similar manner and are picked up by the
>>distributor for formatting and passing on to the delivery channel.
>>
>>You can adjust the frequency at which the generator and distributor
>>check for work, but you cannot get it down to the sub-second level. Even
>>checking once per second would cause the matching query to be execute
>>that often and thus adding somewhat of a load on the system. So if
>>sub-second processing is that important for you, SQLNS is probably not
>>the best solution. Additionally you have 2 very well defined
>>subscribers rather than a multitude of different subscriptions that
>>you'd need to deal with so again, SQLNS may be a bit overqualified.
>>
>>Just my 2 cents here....consider your alternatives and see which one is
>>the best. You may find that even though it's not quite an ideal fit for
>>SQLNS, it may turn out to be the best alternative. Maybe not though...
>>Whatever you decide, would you share your decision with the group so we
>>can learn?
>>
>>
>>HTH...
>>Joe Webb
>>
>>~~~
>>Get up to speed quickly with SQLNS
>>
http://www.amazon.com/exec/obidos/tg/detail/-/0972688811 >>
>>
>>
>>sleepyjoe wrote:
>>
>>>These web services are part of larger document management system, these
>>>web services will in fact start down loading some documents, images
>>>after the notification.
>>>
>>>The requirement is to have notification running with in sub seconds.
>>>The quantum number you mentioned make me believe that SQL NS is a
>>>polling system it does not actually a event driven system as such.
>>>Sure, events are generated but they are delivered based on Quantum
>>>number. Is this assumption is right?
>>>