﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Angel Blanco commented on RavenDB Session Management with NServiceBus</title><description>The code shown does not work, since nservice bus calls HandleEndMessage() before HandleError() and thus, even if an error occurs, changes would get saved.</description><link>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment12</link><guid>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment12</guid><pubDate>Sun, 06 Nov 2011 21:11:29 GMT</pubDate></item><item><title>Ayende Rahien commented on RavenDB Session Management with NServiceBus</title><description>Oh, yeah, I am sorry, you are correct, this is a bug in the code in the post, fixed now</description><link>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment11</link><guid>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment11</guid><pubDate>Tue, 25 Oct 2011 08:52:53 GMT</pubDate></item><item><title>Viktor commented on RavenDB Session Management with NServiceBus</title><description>sorry for my bad explanation.
with "RavenSessionModuleStore store;" i mean that your RavenSessionMessageModule will not compile,
because "RavenSessionMessageModule store;" should be "IDocumentStore store;"
or see below
Viktor

  public class RavenSessionMessageModule : IMessageModule
    {
        readonly ThreadLocal&lt;IDocumentSession&gt; currentSession = new ThreadLocal&lt;IDocumentSession&gt;();

        readonly IDocumentStore store;
        public RavenSessionMessageModule(IDocumentStore store)
        {
            this.store = store;
        }

        public IDocumentSession CurrentSession
        {
            get { return currentSession.Value; }
        }

        public void HandleBeginMessage()
        {
            currentSession.Value = store.OpenSession();
            currentSession.Value.Advanced.UseOptimisticConcurrency = true;
        }

        public void HandleEndMessage()
        {
            using (var old = currentSession.Value)
            {
                currentSession.Value = null;
                old.SaveChanges();
            }
        }

        public void HandleError()
        {
            using (var old = currentSession.Value)
                currentSession.Value = null;
        }
    }
</description><link>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment10</link><guid>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment10</guid><pubDate>Tue, 25 Oct 2011 08:48:45 GMT</pubDate></item><item><title>Ayende Rahien commented on RavenDB Session Management with NServiceBus</title><description>Viktor,
I don't see any RavenSessionModuleStore  there, I see the DocumentStoreFactory, which seems to be mostly about preserving the current session, which is fine</description><link>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment9</link><guid>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment9</guid><pubDate>Tue, 25 Oct 2011 07:27:36 GMT</pubDate></item><item><title>viktor commented on RavenDB Session Management with NServiceBus</title><description>what do you think about this approach?
https://github.com/NServiceBus/NServiceBus-Contrib/blob/master/src/SagaPersisters/RavenDB/NServiceBus.SagaPersisters.RavenDB/RavenDBMessageModule.cs

btw.
i think "RavenSessionModuleStore store;" should be "IDocumentStore store;"
viktor</description><link>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment8</link><guid>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment8</guid><pubDate>Tue, 25 Oct 2011 01:56:24 GMT</pubDate></item><item><title>Ayende Rahien commented on RavenDB Session Management with NServiceBus</title><description>Afif,
That makes absolutely no sense, I am afraid. The only thing in the IDocumentSession that relates to the lifetime of the session is the Dispose method, and trying to create a new interface just to hide that seems silly</description><link>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment7</link><guid>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment7</guid><pubDate>Wed, 10 Aug 2011 14:59:21 GMT</pubDate></item><item><title>afif commented on RavenDB Session Management with NServiceBus</title><description>would it make sense if the message handlers get injected an interface to an IDocumentSession that does not have functionality to open, close, commit, dispose etc. for e.g. an ICurrentDocumentSession or something like that. 
that way we are more explicitly modelling the fact that the session instance injected to message handlers is only providing a window into an open session...
your thoughts?</description><link>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment6</link><guid>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment6</guid><pubDate>Mon, 08 Aug 2011 22:37:22 GMT</pubDate></item><item><title>JarrettV commented on RavenDB Session Management with NServiceBus</title><description>I was worried when I first saw this post but after re-reading the following it seems ok:

"The biggest challenge relates to not having a “final”-type method.  While message modules do expose HandleEndMessage and HandleError, we have no way of knowing which will be called last.  True, HandleError will always be called after HandleEndMessage, but we have no way to determine if HandleError will be called once HandleEndMessage is invoked.  Note that HandleEndMessage is always called, even in error conditions."

http://blog.jonathanoliver.com/2010/04/extending-nservicebus-thread-specific-message-modules/</description><link>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment5</link><guid>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment5</guid><pubDate>Fri, 05 Aug 2011 21:02:03 GMT</pubDate></item><item><title>Ayende Rahien commented on RavenDB Session Management with NServiceBus</title><description>Thanks, fixed</description><link>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment4</link><guid>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment4</guid><pubDate>Thu, 04 Aug 2011 12:13:40 GMT</pubDate></item><item><title>Ryan Heath commented on RavenDB Session Management with NServiceBus</title><description>HandleBeingMessage should be HandleBeginMessage

// Ryan</description><link>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment3</link><guid>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment3</guid><pubDate>Thu, 04 Aug 2011 12:11:48 GMT</pubDate></item><item><title>Ayende Rahien commented on RavenDB Session Management with NServiceBus</title><description>Scooletz,
That depend on what scenarios you have. In our case, we need to call SaveChanges if it didn't error.
The NSB API doesn't give us much other choices.</description><link>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment2</link><guid>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment2</guid><pubDate>Thu, 04 Aug 2011 10:53:02 GMT</pubDate></item><item><title>Scooletz commented on RavenDB Session Management with NServiceBus</title><description>I do prefer to use one message module for all the object with PerRequest lifecycle. What if you needed another one, you'd copy the module?</description><link>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment1</link><guid>http://ayende.com/71681/ravendb-session-management-with-nservicebus#comment1</guid><pubDate>Thu, 04 Aug 2011 10:43:19 GMT</pubDate></item></channel></rss>