Is there any way to have a message handler run outside of an exception?

14 views
Skip to first unread message

Brett Bailey

unread,
May 11, 2015, 1:12:36 PM5/11/15
to nginn-me...@googlegroups.com

The question is in the subject :-)  but for background:

I'm working on a multi-tenancy website portal for our business partners. Each partner organisation we grant access to gets their own sql database for their own data. which is a copy of a template baseline database.

The idea is that when an agreement is made with a partner the details are entered into one of our internal systems and this publishes a message via nginn to the portal which then makes a copy of the template database and performs all the provisioning steps you would imagine.

I am copying the database by backing up and restoring the template database.  

I've built a prototype using the message bus and realised that my I cannot run backup and restores inside of a transaction which is a problem because nginn starts a transaction before my handler is called.


Usually the nginn transaction policy is exactly what I need but for this particular case it is caught me out.

Any Ideas?







Rafal Gwizdala

unread,
May 11, 2015, 2:06:09 PM5/11/15
to nginn-me...@googlegroups.com
Hi Brett,

Yes, backup/restore is a non-transactional operation but i never tried to run it as a part of a transaction so you'll have to test if these ideas work:
1. Enclose your operation in a transaction scope with 'TransactionScopeOption.Suppress', this should prevent any db connections you're opening from joining the message bus transaction
2. Use a separate db connection for the restore operation, adding Enlist=false to the connection string 
3. If your db backup/restore takes a long time (> 1 minute) you can consider doing this outside of nginn transaction (initiate the operation with one message and publish a 'database ready' message when the operation is done), plus add some check/timeout for retrying the operation if it's interrupted in the middle or reporting a problem when it doesn't complete in assigned time

Best regards
RG

--
You received this message because you are subscribed to the Google Groups "nginn-messagebus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nginn-messageb...@googlegroups.com.
To post to this group, send email to nginn-me...@googlegroups.com.
Visit this group at http://groups.google.com/group/nginn-messagebus.

Brett Bailey

unread,
May 13, 2015, 3:39:19 AM5/13/15
to nginn-me...@googlegroups.com
Thanks Rafal This worked a treat!

~Brett
Reply all
Reply to author
Forward
0 new messages