views:

159

answers:

1

I have core library of code which has multiple front ends. One front end is a WCF service, another is a console app that just launches some long running commands which perform financial calcs and other business logic. I am trying to figure out how to manage my ISession in the console app. I 'could' just have one session per "command", but some of the commands are long running process and I am worried about having a session open for that long and/or it getting too bloated. Any pointers for this type of scenario?

Managing the NH session in a web app is so much easier... ;)

+1  A: 

You could either have the ISession flush periodically (say every 5-30 seconds, depending on the amount of inserts/updates/deletes being performed) or when it is critical. I recently used AOP functionality in the Spring .Net framework to execute after certain methods were executed in a process that would take perhaps 30 minutes to complete.

WiseGuyEh
So you are suggesting one ISession and flushing when necessary? I was toying with that. What happens if in a process I get an exception? I can dispose of the session but then I need to create a new one because I have to continue further operations.
Bob
As long as your console app. does not run on multiple threads/processes, a single ISession should work fine. If an exception is thrown in your application, you will have to face the possibility that you might loose some data- however you could allways try to flush the ISession in error handling code as well.Rather than recreating the ISession after calling Flush(), just call the Clear() method. Clear() will remove all "meta" information about objects from the ISession- with large/lengthy operations this can build up and really slow down performance.
WiseGuyEh