After a bit of a delay (VSLive, my wedding anniversary, helping to launch the first meeting of the NYC ALT.NET user group, and a bit of a push for a project at work), I am pleased to announce that the next installment in the Summer of NHibernate Screencast series is now (finally!) available for immediate download.
In this installment we take a look at methods and patterns for managing the lifecycle of the NHibernate ISession object both within and across each HTTP request/response pair. Understanding the techniques and approaches to managing this as well as comprehending the pros and cons of different strategies is essential for any non-trivial web application to scale properly while using NHibernate as its data-access-technology and so we spend some time digging into the mechanics of how all this can be made to work.
In this session we investigate and discuss the Session-per-Request pattern for times when the ISession needs to just live long enough to service a single page request and also the Session-per-Conversation pattern for times when a single ISession instance needs to be leveraged across multiple page requests in order to choreograph more complex interactions between the application and the database.
As always, comments and feedback are encouraged.
Steve,
Most excellent! I’ve been looking forward to this one since you announced the expanded curriculum.
Thanks for your great work on this series – I’ve found it to be invaluable in my efforts to get started with NHibernate.
Ben
I have downloaded twice, but the video finish after 57′ and 44″ without an ending.
What’s wrong? My mistake or a problem with the server?
Thanks, and wonderful work.
Cristiano
@Cristiano:
I’ll be damned — I just played back the video and have confirmed your observation — the video is indeed truncated. Something must have gone wrong with the encoding process (even though no errors were reported by CAMTASIA).
I will have to re-encode it this evening and post a new download; sorry about that~!
I’ve never had any issues with CAMTASIA causing any trouble and so I never even thought to play back more than the first few minutes of the video.
I will post a replacement before tomorrow morning (the RAW camtasia recordings are on my PC @ home so I cannot do thus until I get home from work this evening).
Again, sorry about that~!
Toward the end of the screencast, when you were demonstrating the ISession lifetime, I think there was a bug.
Once the NHIBERNATE_CONVERSATION_END_FLAG_KEY is set, it is never reset. Therefore each time a request is made the HttpModule thinks the conversation has ended.
Steve,
I’m wondering about the use of the BeginTransaction, Rollback and Commit calls in the HTTP Modules. My understanding from Videos 4, 12 and 14 is that these methods might best be called within DataProvider classes.
Are you suggesting in this video that the Http Module transactions should replace the DataProvider transactions in Web Apps?
Thanks again for this series,
Mark
@Mark:
Sort of, yes.
The intent of the series was less about specific advice on implementation patterns and more about the mechanics of using NHibernate to interact with your database. As such, the scoping/bounding of transactions WITHIN the DataProvider class used in the series was more about giving me a place to demonstrate those concepts (transactions and others) rather than necesarily entire implementation patterns.
In the episode where I demonstrate some techniques for managing long-running transactions in web applications, you do start to see some examples of thesre more complex implementation patterns start to surface.
In the Autumn-of-Agile series, it was my intent to dig into some of these more common patterns and to demonstrate their application in that project; I will likely resume the series soon which will permit me to dig back into those issues in more detail in a less-demo-code-like context using more real-world techniques.
Thanks for the feedback,
-Steve B.
I thought this session was a good blend of both theory and practical knowledge. Just checking, is this implementation thread safe since we are only storing the ISessionFactory as static and not the ISessions themselves?