Transactions and Consuming / Publishing in the same host

17 views
Skip to first unread message

Joe

unread,
Jun 29, 2011, 4:04:11 PM6/29/11
to rhino-t...@googlegroups.com
I have an MVC3 app that sends commands (messages) to a console app server.
There server is setup as such:

        private static void Main(string[] args)
        {
            var host = new RemoteAppDomainHost(typeof (BootStrap));
            host.Start();

            Console.WriteLine("Starting to process messages");
            Console.ReadLine();
        }

When a message is consumed, I am also publishing a new event message:

        public void Consume(InactivateProgramCommand message)
        {
            var program = dbContext.Get<ProgramEntity>(message.ProgramId);

            program.Inactivate();
            
            serviceBus.Notify(new ProgramInactivatedEvent{ProgramId = message.ProgramId});
        }

And then consuming that new message in another consumer.

This appears to be working fine, but I am wondering if this is the "preferred" way to do this? 

One the things that concern me is the transactions. I have a NHibernateMessageModule in place similar to the module in Ayende's Alexandria and when watching the sessions in NHProf I can see that each session comes in and the first statement is "enlisted session in distributed transaction with isolation level: ReadCommitted", then the SQL then "commit transaction". 

I am thinking these are two separate transactions and there is NOT one transaction wrapping them both, which is what I want. I want each consumer on its own transaction. Is this correct?

Thanks,
Joe

Corey Kaylor

unread,
Jun 29, 2011, 4:09:50 PM6/29/11
to rhino-t...@googlegroups.com
Yes, you are correct.

--
You received this message because you are subscribed to the Google Groups "Rhino Tools Dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rhino-tools-dev/-/VwSf7J_A7sUJ.
To post to this group, send email to rhino-t...@googlegroups.com.
To unsubscribe from this group, send email to rhino-tools-d...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rhino-tools-dev?hl=en.

Reply all
Reply to author
Forward
0 new messages