Groups | Blog | Home
all groups > dotnet component services > june 2004 >

dotnet component services : How to create and use a Transaction Broker



Thunder
6/1/2004 8:27:52 AM
Greetings,

I am trying to create a Transaction Broker component that can be
instantiated to "setup" a new transaction. Once the TransBroker establishes
a new transaction, I would like to call my other serviced components and
have them enlist in the transaction of the TransBroker.

This is proving to be difficult as I cannot find the correct way to
instantiate the "other" components within the context of the TransBroker.

In the old days, we could use ObjectContext.CreateInstance(), but I cannot
find a similar method that will allow me to create "serviced components"
within the context of the primary object- the Trans Broker.

Any ideas would be appreciated.

-Michael

Florin Lazar [MSFT]
6/3/2004 12:08:59 AM
Hi Michael,

Simply using new to create the other serviced components should be enough.
I'm assuming that these other components are marked Transaction "Required"
or "Supported".

Regards,
--
Florin Lazar - Microsoft - [ http://blogs.msdn.com/florinlazar ]
Please do not send email directly to this alias. This alias is for newsgroup
purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.

[quoted text, click to view]

Thunder
6/4/2004 4:56:27 PM
Florin,

The NEW keyword is not having the affect I desire. Perhaps I did not state
the problem correctly.

"How does one go about creating serviced components in the context of
another serviced component- all from the front end???"

Consider this...

I have 3 simple serviced components in COM+. One component is called the
Transaction Broker and it "requires a new transaction". The other two
components actually do the work. All three components are instantiated by
the FORM(client)

The usage scenario is simple... A form- on the client- instantiates the
Transaction Broker. The form then instantiates the other two serviced
components and tells them to SAVE(after doing some work). Problem is that
the components are not "in the transaction".

The behavior I am looking for is to have the two serviced components
"enlist" in the transaction of the Broker object so that I can roll back.
Currently this is not happening.

How does one go about creating serviced components in the context of another
serviced component- all from the front end???

When

[quoted text, click to view]

Marcelo Dabanovich Lavio
6/8/2004 11:10:56 AM
Hi Thunder,

If your front end instantiates the transaction broker component and the 2
worker components as you stated, then this 2 worker components cannot "see"
(or enlist to) the transactional context of your transaction broker
component. This is because com+ is a runtime based on call interception.

If your front end instantiates the transaction broker, and if the
transaction broker, in turn, instantiates the other 2 components, then all
can share (if the transaction options are right) the same transaction,
because there is a call chain which enables COM+ runtime to know what to do
(because it intercepts each call, and while it knows the context of the
caller component, it also knows the requirements of the callee component,
and can act accordingly, ie, it can "flow" the transaction context). If your
front instantiates the 3 components by itself, there is no such "call
chain", because your front end has no transaction set in the call context
when it instantiates any of the components.

The only thing I can think of, which will require some research of your own,
it's to investigate if the BYOT feature of COM+ can be of any help on your
case (BYOT is Bring Your Own Transaction). But it may not be worth the
price. Maybe a redesign of your app can get you a better return.

Marcelo


[quoted text, click to view]

Thunder
6/12/2004 9:34:22 PM
The solution was very simple... The forms in my "front end" app do in fact
create the "transaction broker" when needed. Then, the trans broker is
passed to the BOs behind the form. At that time, the BOs understand that a
transaction is in progress, and ask the TransBroker to create the
appropriate DAL.

In short, when the "form" uses the trans broker, the BOs allow the trans
broker to create the DAL objects, as oppossed to creating them by
themselves.

It worked perfectly. Thanks for all the feedback,

-Thunder
[quoted text, click to view]

AddThis Social Bookmark Button