You just redispatch the message. Transactions are message scoped.

eg:
When processing message1 you decide you want to do some other long
running operation.
commit transaction for message1 dispatch message2

message2 is received start a new transaction. if you fail here and
need to rollback message1 you use what is called a compensating
action.

Also you never send a message to a particular thread ... just dispatch
the message, if you are threaded they will be processed multi-threaded
if you are not they will be processed single threaded. This
disconnection between sender and receiver (or publisher/receiver
depending on the intention) is very important for these types of
systems.

On Sun, Jan 9, 2011 at 7:44 PM, hoghweed <[email protected]> wrote:
> Thanks Greg,
> this could be very interesting. Sorry for my simple simple reply..
> Starting from what you said, I can dispatch a message, that would be
> handled in a specific thread,
> and there the session would be associated to the executing thread?! I
> Understood what you said?
> pleas could be more explicative?
> Thanks in advance
> Your reply is the first really serious reply on that problem/question
> Cheers
>
> On Jan 7, 5:30 pm, Greg Young <[email protected]> wrote:
>> If its a state machine/messaging server the easy answer would be to
>> commit and dispatch the new message (which would then get picked up)
>> as opposed to starting a new thread. This style is a well known
>> pattern in messaging state machines.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Fri, Jan 7, 2011 at 10:02 AM, hoghweed <[email protected]> wrote:
>> > Thanks, I know what you said but It's not the kind of help I was
>> > looking for!
>> > Regards.
>>
>> > On Jan 7, 11:54 am, FaticaLabs <[email protected]> wrote:
>> >> Hi hoghweed,
>> >> AFAIK a session should not be used across threads, since session is
>> >> not thread safe.
>> >> Felix.
>>
>> >> On Jan 7, 1:46 am, hoghweed <[email protected]> wrote:
>>
>> >> > I'm building a sort of a state-machine server based on xml and json as
>> >> > description, a kind of "workflow server" (even if i hate workflows..)
>> >> > I'm using NH as persistence.  Thisea "server" is hosted in a Windows
>> >> > Service and makes usage of multithreading.
>>
>> >> > The server receives notifications and messages, when a message arrives
>> >> > a NH session is spawned and lives through the life of a message, till
>> >> > here all could be fine.
>> >> > There are some messages which creates a new thread to perform some
>> >> > actions, and I need that threads using the same Session created in the
>> >> > message "context".
>>
>> >> > I made a big error, as Ayende say everytime, I used a framework over
>> >> > NH, the framework is NCommon (https://github.com/riteshrao/ncommon)
>> >> > which use a kind of SessionScope which makes a kind of "context", so
>> >> > nested SessionScopes creates unit-of-work inside the outer, the first
>> >> > one created.
>>
>> >> > I know NH use the ability to get a SessionContext where it's possible
>> >> > to bind a session in a particular context, so it's possible to get the
>> >> > current session from the sessionfactory.
>>
>> >> > How to make possible to use the message-context-created session to
>> >> > threads created in this particular message-context? could a good idea
>> >> > to create a custom sessioncontext class, and associate a session to a
>> >> > kind of a message-id? if so, how, and what's the best way to associate
>> >> > that threads to that message-id?
>> >> > Thanks in advance
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "nhusers" group.
>> > To post to this group, send email to [email protected].
>> > To unsubscribe from this group, send email to 
>> > [email protected].
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/nhusers?hl=en.
>>
>> --
>> Les erreurs de grammaire et de syntaxe ont été incluses pour m'assurer
>> de votre attention
>
> --
> You received this message because you are subscribed to the Google Groups 
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/nhusers?hl=en.
>
>



-- 
Les erreurs de grammaire et de syntaxe ont été incluses pour m'assurer
de votre attention

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to