Working with transactions within Orchard

Topics: Customizing Orchard
Jul 18, 2012 at 10:36 AM

I know Orchard uses an ambient transaction for all work you perform on the data in the system. This is fine for most situations, but I've run into a situation where I don't want this to happen.

I'm trying to import a huge taxonomy into the taxonomy module using a custom command I've made for this. It contains 10k keywords in a text file in a hierarchy that is about 8 levels deep at some points.

When I try to import this set of keywords, it fails at about 10% of the list, because of a transaction time out. I can ofcourse try to increase the transaction timeout, but this isn't the best way to approach the situation if you ask me.

I'd like to have one transaction for each term I'm importing. The reason is simple, if it fails half way I can always go back and retry the operation. The command is built in such a way that I check if the term exists and skip importing it if it does. So retrying is no issue.

I've found a way to supress the ambient transaction,. but no proper way to create a separate transaction per item. Is this possible in Orchard?

Jul 18, 2012 at 4:00 PM

ITransactionManager.Demand() ??

Jul 19, 2012 at 9:44 AM

True, but that only creates a new scope. I also want it to complete explicitly when I tell it to, without disposing the transaction manager itself.

Coordinator
Jul 23, 2012 at 1:44 PM

You may have to schedule the work in batches. I think there are examples of that in the export/import module.

Aug 1, 2012 at 3:51 PM

Why yes, yes there is an example in the import/export module, but it's in it's use of code in the Recipe module. Using the ProcessingEngine is pretty slick too.

Aug 1, 2012 at 5:20 PM

 

http://orchard.codeplex.com/discussions/273971