473,372 Members | 1,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

Using CallContext to store request specific objects

Can the CallContext be used reliably for storing request specific data?

We are developing an application library that uses the CallContext to keep
an IdentityMap (hashtable of business objects that have been loaded from the
DB) and a collection of business objects that have been modified during the
current request. These object maps need to be globally visible throughout a
request and expire at the end of it. The maps are accessed using static
methods of a manager class which uses CallContext.GetData().

For example: If two different web requests load a Person
object with an ID of 100, then two reads would be performed on the database
and two IdentityMaps would be created. Within one executing web request, if
a Person object with an ID of 100 is read twice then the second object would
would come from the IdentityMap.

This is working great in our development environment but we have some
concerns that under load the CallContext may not be unique to the current
request and may not be the best choice for this. However, since the
application can be used outside of a web context the HttpContext could not be
used.
Nov 19 '05 #1
3 2762
Hi Exclusive,

Welcome to ASPNET newsgroup.
Regarding on the question you mentioned, I think your current approach on
using the CallContext should be OK and due to the limitation that you can
not utilzie the HttpContext class, I'm afraid there hasn't any other better
buildin interfaces for maitains data during execution path. Also, the
current implementation of the HttpContext.Current also utilize the
Callcontext to associate the context data with the executing asp.net
serverside request. In addition, if your class component is only used in
single appdomain scenario, we can also consider implementing a custom class
which use static class member to hold a collection which store the data for
each request by a identity number...

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| Thread-Topic: Using CallContext to store request specific objects
| thread-index: AcXY7bAMKWoJJsSTS4GNrK2YMPbGbQ==
| X-WBNR-Posting-Host: 198.67.7.2
| From: "=?Utf-8?B?RXhjbHVzaXZlUmVzb3J0cw==?=" <ex*******@noemail.noemail>
| Subject: Using CallContext to store request specific objects
| Date: Mon, 24 Oct 2005 15:53:02 -0700
| Lines: 20
| Message-ID: <B4**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:133594
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Can the CallContext be used reliably for storing request specific data?
|
| We are developing an application library that uses the CallContext to
keep
| an IdentityMap (hashtable of business objects that have been loaded from
the
| DB) and a collection of business objects that have been modified during
the
| current request. These object maps need to be globally visible
throughout a
| request and expire at the end of it. The maps are accessed using static
| methods of a manager class which uses CallContext.GetData().
|
| For example: If two different web requests load a Person
| object with an ID of 100, then two reads would be performed on the
database
| and two IdentityMaps would be created. Within one executing web request,
if
| a Person object with an ID of 100 is read twice then the second object
would
| would come from the IdentityMap.
|
| This is working great in our development environment but we have some
| concerns that under load the CallContext may not be unique to the current
| request and may not be the best choice for this. However, since the
| application can be used outside of a web context the HttpContext could
not be
| used.
|

Nov 19 '05 #2
Steven,

Thanks for the quick response. In your response you said that our approach
to using the CallContext “should be ok”. We were wondering if you could be a
little more specific.

Again, our concern is that the integrity of the data contained in the
CallContext may not be maintained during instances of high traffic and
concurrency on the web server.

We have read that the CallContext is tied to a thread. We have also read
that the processing of a single asp.net page and all of it’s business objects
cannot be guaranteed to execute on the single thread. Because of this we
have deduced that CallContext may not be a reliable source of data.

Specific Questions:

Is the processing of a single asp.net page and all of it’s business objects
tied to a single thread?

Is there a limit to the amount of data you can store in the CallContext?

Can we be assured that the data contained in the CallContext is only
available to each specific request?

Is all memory ‘released when the thread a request executed on is given back
to the thread pool?

Is there an easy way to test the above and be assured we will not have any
issues?
Nov 19 '05 #3
Thanks for your response,

For your further question:

1) Is the processing of a single asp.net page and all of it’s business
objects
tied to a single thread?
================================
Yes, ASP.NET runtime will pickup a .net managed thread pool thread from CLR
thread pool when a new asp.net request arrive the asp.net runtime. Then,
that worker thread is associated with that request during serverside
processing/lifecycle. After that request eneded, the worker thread return
to the threadpool again for sequential use. New thread will be involved
only when we manually create new thread to do works or use asynchornous
method invoking (e.g. delegate.BeginInvoke....)
2)Is there a limit to the amount of data you can store in the CallContext?
================================
As far as I known, there hasn't any documented limitation on the
CallContext's data storage. It'll depend on the actual server's memory just
like sessionstate or asp.net runtie Cache....
3)Can we be assured that the data contained in the CallContext is only
available to each specific request?
================================
Of course I think so. As I mentioned, the "HttpContext.Current"( which
always point to the HttpContext of the current asp.net request/worker
thread) ) just utilize the CallContext to retrieve the stored Context
object, so the CallContext is reliable.
4)Is all memory released when the thread a request executed on is given
back
to the thread pool?
================================
Do you mean all the memory of the data stored in the CallContext? If so, I
think they'll be cleared because CallContext is a very context sensitive
field which should be reset before the thread pool thread be resued next
time. However, for some other properteis of the Thread pool thread, we're
not gurantee that they'll be reset(because for performance consideration,
thread pool thread won't intialize all the fields/properties before being
picked to serve a certain request.
5)Is there an easy way to test the above and be assured we will not have
any
issues?
=================================
No definite answer on this. For low workload scenario, I'm sure this will
works ok. So the simplest means I can get is performing high workload
concurrent test on this. ( you can increase he maxWorkerThreads setting in
<processModel> cofiguration section in machine.config according to your
requirement and machine's hardware )

<processModel> Element
http://msdn.microsoft.com/library/en...cessmodelsecti
on.asp?frame=true

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| Thread-Topic: Using CallContext to store request specific objects
| thread-index: AcXZhUXWJ0a/cEImRsmvVJgGBUgc7A==
| X-WBNR-Posting-Host: 198.67.7.2
| From: "=?Utf-8?B?RXhjbHVzaXZlUmVzb3J0cw==?=" <ex*******@noemail.noemail>
| References: <B4**********************************@microsoft.co m>
<YC**************@TK2MSFTNGXA01.phx.gbl>
| Subject: RE: Using CallContext to store request specific objects
| Date: Tue, 25 Oct 2005 09:58:07 -0700
| Lines: 30
| Message-ID: <EE**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 8bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:133753
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Steven,
|
| Thanks for the quick response. In your response you said that our
approach
| to using the CallContext “should be ok? We were wondering if you
could be a
| little more specific.
|
| Again, our concern is that the integrity of the data contained in the
| CallContext may not be maintained during instances of high traffic and
| concurrency on the web server.
|
| We have read that the CallContext is tied to a thread. We have also read
| that the processing of a single asp.net page and all of it’s business
objects
| cannot be guaranteed to execute on the single thread. Because of this we
| have deduced that CallContext may not be a reliable source of data.
|
| Specific Questions:
|
| Is the processing of a single asp.net page and all of it’s business
objects
| tied to a single thread?
|
| Is there a limit to the amount of data you can store in the CallContext?
|
| Can we be assured that the data contained in the CallContext is only
| available to each specific request?
|
| Is all memory ‘released when the thread a request executed on is given
back
| to the thread pool?
|
| Is there an easy way to test the above and be assured we will not have
any
| issues?
|

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Aaron | last post by:
The following code works fine when previewing a Crystal report using ASP, EXCEPT when it gets to a report using a SubReport and its associated parameters. The whole report just comes up blank with...
0
by: A Rothberg | last post by:
Have some questions about the behavior of CallContext and visibility to the CallContext data. Can someone please confirm (or deny) that the observed behaviors are by design and will not be...
0
by: Jos Joye | last post by:
I'm playing around with the "CallContext" class to pass around extra information between my client and Server applications (implemented with Remoting). My Server is a SAO-singlecall. If I try...
2
by: Jos Joye | last post by:
I'm playing around with the "CallContext" class to pass around extra information between my client and Server applications (implemented with Remoting). My Server is a SAO-singlecall. If I try...
5
by: Pham Nguyen | last post by:
Hello, Is it appropriate to use the CallContext class for storing request-specific data? I have a set of business objects that I'm building. Each class contains a hashtable that maps from a key...
2
by: Mel | last post by:
This may be a stupid question, but here goes... I have created a NameValueCollection in my website's application state. If, during a page request, I add a string key and string value to the...
21
by: matvdl | last post by:
I have a system that was originally developed in asp - the pages are saved in SQL (there are over 10,000 pages) and saved to a temp directory in the server when requested by a client. I have...
1
by: Tommaso Caldarola | last post by:
If I call System.Runtime.Remoting.CallContext.SetData() and then I call System.Runtime.Remoting.CallContext.GetData() from a different thread I get null, if the thread indeed is the same I get...
5
by: Charles Zhang | last post by:
I am creating dynamic web pages according to the user inputs from a web page. For instance, a user typed in a text, I would want the text being the source code of the dynamic page. My...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.