[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.caching

SqlCacheDependency for multiple ASP.NET applications

Stu

4/25/2007 6:44:00 PM

I would like the caches of three ASP.NET applications to each have a cache
entry with a SqlCacheDependency on a specific record in a SQL 2005 database.
When that record is deleted I would like the cache entry to all three caches
to be removed. In some preliminary tests I've found that only one out of the
three caches would be notified of the change. However, I can prove that query
notifications are working properly for all three apps: if I test them
individually they work as expected.

It seems to me as though there is only one event and it is consumed by the
first app to receive it. Is there something I need to do to get all three
apps to be notified correctly?
4 Answers

stcheng

4/26/2007 9:24:00 AM

0

Hi Stu,

From your description, you're using ASP.NET 2.0's SqlCacheDependency with
SQL Server 2005 database. However, you found that when you have multiple
applications that register notification to the same SQL 2005 database(and
table), only one of the application will receive query notification and
invalid the cache, correct?

Based on the symptom, I have performed some test on my local side, here are
my test environment:

** windows XP sp2 box with IIS5, ASP.NET 2.0 and SQL Server 2005 (express
edition)

** database have enabled query notification(enable service broker)

** create two ASP.NET 2.0 websites and both of them start SqlDepenency at
Application_Start and point to the same SQL 2005 database.

I use SqlDataSource control to test the query notification, as below:

======================
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:CacheDBConnectionString %>"

SelectCommand="SELECT [id], [name], [description] FROM [cache_table]"
CacheDuration="1000" EnableCaching="True"
ProviderName="<%$ ConnectionStrings:CacheDBConnectionString.ProviderName
%>"
SqlCacheDependency="CommandNotification">
............
=-=====================

However, when I update the table records(insert, remove...) in SQL Server
2005 management studio, both the two applications can correctly get the
updated dataset (the SqlDataSource control will requery the database for
new dataset). Therefore, I think the problem is likely specific to the
certain applicatoin, such as the code logic on how to use the query
notification. You can try testing the above appraoch and compare to your
SqlCacheDepenency code logic to see whether there is anything different.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default....
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/de....

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.


Stu

4/26/2007 11:06:00 AM

0

Hi Steven.

Glad to know that it should work!
Actually, I have since found that my code works fine sometimes. But it seems
that during debugging sometimes it doesn't work. I suspect that starting and
stopping the application several times during debugging may be causing the
problem. As long as I don't debug it seems to be ok.

Thanks for your help.

Stuart

Remus Rusanu [MSFT]

4/26/2007 4:04:00 PM

0

Are you using the default behavior of SqlDependency? that is, you let it
create a separate service/queue for each appdomain, or are you overwriting
this and set all appdomains to receive from the same queue?

I have some basics on how to troubleshoot QN at
http://blogs.msdn.com/remusrusanu/archive/2006/06/17/6...
- Have you looked if the notifications are fired? (Use profiler to monitor
the QN events)
- If the notifications are fired, are they delivered? (look in
sys.transmission_queue)
- If they are delivered, are they dequeued by the right appdomain? (use
profiler to monitor SQL batches)

You mention in your other post that this happens only if you debug, a
typical problem of debugging Service Broker related apps is unvilingly
triggering the poison message detection (because of breakpoints set in app
during a transaction and intrerupting the app, thus rolling back), as
described here: http://msdn2.microsoft.com/en-us/library/ms1...

HTH,
~ Remus

--
This posting is provided "AS IS" with no warranties, and confers no rights.

HTH,
~ Remus Rusanu

SQL Service Broker
http://msdn2.microsoft.com/en-us/librar...(en-US,SQL.90).aspx


"Stu" <stu@community.nospam> wrote in message
news:24681554-F805-46CA-A2D1-1468CB825613@microsoft.com...
>I would like the caches of three ASP.NET applications to each have a cache
> entry with a SqlCacheDependency on a specific record in a SQL 2005
> database.
> When that record is deleted I would like the cache entry to all three
> caches
> to be removed. In some preliminary tests I've found that only one out of
> the
> three caches would be notified of the change. However, I can prove that
> query
> notifications are working properly for all three apps: if I test them
> individually they work as expected.
>
> It seems to me as though there is only one event and it is consumed by the
> first app to receive it. Is there something I need to do to get all three
> apps to be notified correctly?


stcheng

4/27/2007 4:03:00 AM

0

Thanks for your reply Stuart,

Yes, for SQL 2005 awared cachedependency, we'll need to start it in
Application initialization time, therefore, in debugging time, it may cause
some problem. Anyway, glad that you've also got it working under normal
running mode.

If you meet any new problem or anything we can help, please feel free to
post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.