Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application data management 1

Status
Not open for further replies.

tlhawkins

Programmer
Dec 28, 2000
797
0
0
US
I'm looking for a method of application variable management that is better (as in Faster, more Robust) than the application object. I need to be able to access these "application" variables from a class.

Here is a rough description of my setup:

VB.Net Presentation layer
VB.Net Business logic layer
C#.Net SOAP Services

SO... I need a way to store/retrieve data about User Sessions at the SOAP Service layer.

I would just use Application variables for this, but I'm wondering if there is a better way? Or any limitations to using Application variables that I should know about before starting.




Travis Hawkins
 
it doesn't (shouldn't) matter what language the services are written in, if.

If the SOAP services are structured correctly it doesn't matter what language they are written in, the communications between client/server is just xml. each request is autonomous so each request would require authentication. this would be some form of a header. Create a SOAP header utility method which defines the soap header(s) for authentication. then it's a standard SOAP call.

this is my undestand of SOAP/web services.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thanks jason,

I see your point and it's well taken. I'm not so worried about the language being used though. The languages chosen for those layers are not variable. The question is, What is the best way to handle Application variables?

see, I'm going to have 100 - 500 incoming sessions at the web layer, I need to funnel that down to 150 sessions going outbound to the SOAP services. Sometimes that will mean 1 SOAP session per user session but at times I'll need 2 or 3 user sessions per SOAP session. so at the SOAP layer I need to keep track of how many user sessions are active, and which SOAP session they are using so I can multiplex when I need to.

SO... would application variables be best for that? Is there any method that would not require me to go serial (as everyone would have to wait for session variable LOCK and UNLOCK).

I'm just trying to do some research and use the best possible method for this as it's a clean write without any prerequisites.

Travis Hawkins
 
would it work, yes. But I wouldn't use the Application space for this. I would create a SOAP session manager and have this object maintain the connections/request/responses. i would use an IoC container like Windsor or Structure.Map to manage my application level objects.

Sometimes that will mean 1 SOAP session per user session but at times I'll need 2 or 3 user sessions per SOAP session.
not understanding your model I can't say whether this is good or bad. This does throw up red flags though.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
The times when user sessions will be multiplexed on SOAP sessions will only be for stateless SOAP transactions. As soon as the user moves to a stateful transaction they will be moved to a SOAP session that they will not share.

I can see no other way to allow 500 users to share 150 SOAP sessions without causing a serious bottle neck. Am I missing another options?

Travis Hawkins
 
not sure I follow. however I'm not familiar enough with SOAP/Web Services to be an authority on the subject.

That said this would be my approach.
1. view SOAP as the interface between the client and server. This interface simply parses/passes the request to the actual service which preforms the given action.
2. treat each request individually.
3. create a scope manage on the server which is responsible for aggregating multiple requests before processing.
4. a request either modifies data, or get data, not both.

Now the SOAP requests are just thin layers which are "dumb".
The client simply makes requests to the server via SOAP. if it needs a response (selecting data) it will wait for the response. otherwise it just fires and forgets.

The client isn't concerned with how/if the requests are aggregated. it just makes requests. The server is responsible for organizing these requests into a unit of work and processing.

if you have a long running request (span multiple SOAP requests) pass a flag with the request so the server knows how to group the requests. then have a commit/process all requests service which takes the flag and process all related requests in one go. I would use a GUID as the flag.

say the example is placing an order. the order can be entered piece-meal.
so 1 request to start the order this request must contain
1. customer
2. po number
3. other order header information
4. 1 line item (product quantity, cost)
5. flag

then another service to append line items containing
1. product
2. quantity
3. cost
4. flag

then another service to process the order (until this point the server is just collecting the request, where/how is up to you).
this service takes just the flag. it would pull the order/line items from temporary storage (file, db, memory) and process (save to db?)

this simplifies the client/server communication. It also make the client completely ignorant to how the server is process requests.

if you are still experiencing latency/timeout issues you can batch requests from the client without concern of the context. (but don't worry about this until it is an issue).

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
That's a wonderful plan if only I had control of the SOAP Server :-(

unfortunately the SOAP server is inaccessible to me.  I have to make my client handle the sessions.  The SOAP server will return a sessionID that can be passed back to retain state if that is necessary,  or a new SOAP session can be created.  The SOAP server limits the number of sessions I can have open.  It's my job to use those limited sessions to serve an unlimited number of web users.

The nuts and bolts of the multiplexing don't seem so difficult, I'm just wondering what is the best method for tracking session usage across users.


Travis Hawkins
 
is there anyway of working with the 3rd party to redesign the service communication? If not then this architecture will become a problem.

if you can great. if not you can still you the same approach above with a slightly different twist. create the Soap manager on the client and have this manager manage the requests. the client will think it's calling the server, when really it's just calling the manager. once the manager gets a "commit" request it will send each request related to the flag.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
I hear ya, it would be great if we could get them to make changes, but that's not going to happen. The rest of the process makes sense...

so, when you say "create the Soap Manager" is there something built in that will do that session management? I haven't seen anything, it looks like I have to create it myself. If that is the case then is httpApplication the class to use to map those SOAP Sessions to User Sessions?

I can think of several ways to track data across sessions but they all require some kind of locking while writing, so my big delima is which method is fastest?

Travis Hawkins
 
yes, you will need to design the Soap Manager.
avoid the Application object when possible. here is a really simple implementation of the manager
Code:
interface ISoapManager
{
   void AddRequest(Guid flag, Request request);
   void SendRequestsFor(Guid flag)
}

class SoapManager : ISoapManager
{
   private IDictionary<Guid, List<Request> requests = new Dictionary<Guid, List<Request>();

   public void AddRequest(Guid flag, Request request)
   {
      if(!requests.ContainsKey(flag))
         requests[flag] = new List<Request>();
      else
         requests[flag].Add(request);
   }

   public void SendRequestsFor(Guid flag)
   {
      foreach(Request request in requests[flag])
         //send request
   }
}
now the scope of the manager can be controller a couple different ways. 1. an IoC container like Structure.Map or Windsor.
2. a static instance. 3. somewhere in between
here is an example of a static instance
Code:
public class SoapManagerScope
{
   public static readonly ISoapManager Instance = new SoapManager();
}
here is how the client code would use this manager
Code:
Guid flag = Guid.NewGuid();
SoapManagerScope.Instance.AddRequest(flag, new SoapRequest());
SoapManagerScope.Instance.AddRequest(flag, new SoapRequest());
SoapManagerScope.Instance.AddRequest(flag, new SoapRequest());
SoapManagerScope.Instance.SendRequestsFor(flag);

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
your welcome. I enjoyed the challenge.
I "gotcha" to look out for. if your web site shuts down (iis restart, server reboot, not visitors for a period of time) then the requests will be dropped.

A solution/hack for this is to add a property to the manager which checks for outstanding requests. in the Global.Application_Stop method wait for all the requests to be processed before completely shutting down.

or (probably a better idea to) serialize the requests and write them to disk before the website stops. When the website starts up again hydrate the serialized message into the manager again. then delete the file(s).

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top