cancel
Showing results for 
Search instead for 
Did you mean: 

How to span DB transaction over whole BLT?

Former Member
0 Kudos

Hi All,

how to achieve transaction ACID properties regarding multiple DB connections over a full BLT? This would require to switch

off autocommit and reuse the same DB connection in serveral actions of the BLT and then issue a commit at the end.

Is this possible? Often we have the need to have transactional semantics of a BLT. Is it possible to leverage this via a custom

action? Is there access to the connection pool of MII from a custom action?

Thanks,

Matthias

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

The simple answer, Matthias, is no, but with custom actions, this would be quite easy to do. Ideally, you could have access to the MII connection pooling system, but if not, you could use JDBC directly to do the same thing. You would need to mirror the concept of the JCO transactions (Begin, Execute, Commit/Rollback), and the "magic" needed here is the ability to pass the database connection between these functions (in particular, the Begin action would create and own it, the others would act upon it).

It would be much easier to do if you had the support of the MII team, and this would be a very natural enhancement request for the product.

Former Member
0 Kudos

Hi Rick,

thanks a lot for the information. Yes, support from the development team would be very much appreciated. This is to have access

to the connection pool and to mimic the functionality of the JCO part. Doing it with JDBC would involve separate credential management,etc. How would the magic be done? Is it like saving the connection in the transaction context and getting the context from the most upper transaction with walking up the tree with getParent and looking for steps that are transactions? With this every custom action could get the same context and retrieve the connection even if transactions call transactions, etc.

How could we get in touch with this?

Regards,

Matthias

Former Member
0 Kudos

You're close to the solution. Actually, the trick is to use the same approach as the JCO actions (and the various MII document actions) that include a String property that "points" to another action (usually by referencing/storing the action's name). Using this reference, inside your custom action, you can get a reference to the "parent" or "context" action, in which you can keep the database connection, and can "cast" it to an interface/class of your choosing to grab the connection from it.

There are a few other methods that an action can expose to help with initialization and cleanup, and make sure you include a database connection cleanup code in case no explicit cleanup action is called.

If you want to use the MII connection pool(s), you'll need to get some sample code from the MII team. It's really only a couple lines of code to use it, but since it isn't a documented API, you'll need to get some help from them. Alternatively, you could use your own connection management, but I'd suggest trying to use the built-in connection pooling.

Basically, I would mimic the design pattern of the JCO actions merged with the capability of the SQLQuery action. It wouldn't be that hard to build those actions if you had access to the MII source (a day of work at most), but trying to write them from scratch could be a bit of a challenge without access to some of the MII internals.

Of course, a lot of the code base has changed between V11 and V12, so the actions will need to be version specific.

Rick

Former Member
0 Kudos

Hi Rick,

thanks for the valuable information. I agree, we should go for the MII pool solution which would integrate better.

Ok, how can I get the code examples for connection pool access, connection clean up code and maybe a hint for the

action reference by name? As this requirement was driven from one of our productive customers are you going to implement

this feature or would like to develop this in teamwork with us?

Regards,

Matthias

Former Member
0 Kudos

Hi, Matthias.

I'm no longer with SAP, but I would suggest contacting Jeremy Good and/or Salvatore Castro at the SAP office in Exton for some assistance in obtaining the documentation and support you'll need, particularly if you are writing the actions for version 12.0, which represents a lot of internal changes to MII.

Rick