New and CreateInstance in COM+ 
Author Message
 New and CreateInstance in COM+

Greeting VBers,

   I had thought all the while that the New keyword in MTS is used to
start
a new transaction context compared to CreateInstance which use the
current
or parent transaction context, is this right?

  I'm debugging a COM+ object which Required Transaction. A call to a
method
will invoke other COM+ objects. Problems is this method (X) invoke
another
COM+ object (Y) using New, but the (Y) still working in the transaction
context of (X)!

  So far my founding of this is by using the SQL Profiler to analyze
method
call to SQL Server. The method (X) will do a looping, which inside is to
delete record on 1 table (handle by Y).

<--snipped-->
ObjX.clsX, Required Transaction
Sub mtdX()
Do While condition
  Set obj = New objY.clsY
  obj.mtdDelete record
  Set obj = Nothing
Loop

  COMSVCSLib.GetObjectContext.SetComplete
End Sub

---------
ObjY.clsY, Required Transaction
Sub mtdDelete(record)
  Get existing record from SQL Server (SELECT * FROM table ...).
  Perform validation...
  Delete record.
  COMSVCSLib.GetObjectContext.SetComplete
End Sub
<--snipped-->

Case #1:If I use the ObjX.clsX.mtdX() to delete 1 record, no problem.
Case #2:If I use the ObjX.clsX.mtdX() to delete more than 1 record; 1st
record deleted OK (which still rollback by ObjX due to 2nd record
timeout),
but 2nd record will timeout inside ObjY.clsY.mtdDelete() line where it's
reading the record.

The duration to retrieve the record is max-out as shown in SQL
Profiler. So
such behaviour obviously indicate table locked by process when 1st
record
is deleted.

If the New keyword does indeed start a new transaction context, 2nd
record
deletion shouldn't be timeout (which probably due to locking). Obviously
the whole process are still executing within a single transaction hood.

Can someone show me how to start a transaction context in the COM+
object
using VB? Or is this a COM+ bug?

Currently we fixed this temporary by modifing the SQL statement to
retrieve
record in ObjY using locking hints (NOLOCK), which simply is not the
correct solution.
e.g. SELECT * FROM table WITH (NOLOCK)

TIA.

--
Yours sincerely,
Kelmen Wong
-----------

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Tue, 14 Jan 2003 03:00:00 GMT  
 New and CreateInstance in COM+

Don't use New to instantiate objects in MTS (except ADO objects).
New will create the objects outside the current context,
but it will not start a new transaction. The second component is
set as Requres so it takes the context of the transaction that created it.
To start a new transaction set the second object as Requires New, and
use CreateObject to instantiate it.

Regards


Quote:
> Greeting VBers,

>    I had thought all the while that the New keyword in MTS is used to
> start
> a new transaction context compared to CreateInstance which use the
> current
> or parent transaction context, is this right?

>   I'm debugging a COM+ object which Required Transaction. A call to a
> method
> will invoke other COM+ objects. Problems is this method (X) invoke
> another
> COM+ object (Y) using New, but the (Y) still working in the transaction
> context of (X)!

>   So far my founding of this is by using the SQL Profiler to analyze
> method
> call to SQL Server. The method (X) will do a looping, which inside is to
> delete record on 1 table (handle by Y).

> <--snipped-->
> ObjX.clsX, Required Transaction
> Sub mtdX()
> Do While condition
>   Set obj = New objY.clsY
>   obj.mtdDelete record
>   Set obj = Nothing
> Loop

>   COMSVCSLib.GetObjectContext.SetComplete
> End Sub

> ---------
> ObjY.clsY, Required Transaction
> Sub mtdDelete(record)
>   Get existing record from SQL Server (SELECT * FROM table ...).
>   Perform validation...
>   Delete record.
>   COMSVCSLib.GetObjectContext.SetComplete
> End Sub
> <--snipped-->

> Case #1:If I use the ObjX.clsX.mtdX() to delete 1 record, no problem.
> Case #2:If I use the ObjX.clsX.mtdX() to delete more than 1 record; 1st
> record deleted OK (which still rollback by ObjX due to 2nd record
> timeout),
> but 2nd record will timeout inside ObjY.clsY.mtdDelete() line where it's
> reading the record.

> The duration to retrieve the record is max-out as shown in SQL
> Profiler. So
> such behaviour obviously indicate table locked by process when 1st
> record
> is deleted.

> If the New keyword does indeed start a new transaction context, 2nd
> record
> deletion shouldn't be timeout (which probably due to locking). Obviously
> the whole process are still executing within a single transaction hood.

> Can someone show me how to start a transaction context in the COM+
> object
> using VB? Or is this a COM+ bug?

> Currently we fixed this temporary by modifing the SQL statement to
> retrieve
> record in ObjY using locking hints (NOLOCK), which simply is not the
> correct solution.
> e.g. SELECT * FROM table WITH (NOLOCK)

> TIA.

> --
> Yours sincerely,
> Kelmen Wong
> -----------

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Tue, 14 Jan 2003 03:00:00 GMT  
 New and CreateInstance in COM+
Mmm... OK, here's a scenario/requiment:

We prepared a COM+ object which set to Required Tranx, as it will run
in any Tranx Context either on it's own or in other caller's Context.
So this design became as our standard protocol in creating COM+ object.

But it come into a situation where this object will invoked by other
COM+ object running in a Tranx Context, but need this object to execute
in a separate Tranx Context. Is this possible without changing the
tranx setting of the object using VB?



Quote:

> Don't use New to instantiate objects in MTS (except ADO objects).
> New will create the objects outside the current context,
> but it will not start a new transaction. The second component is
> set as Requres so it takes the context of the transaction that
created it.
> To start a new transaction set the second object as Requires New, and
> use CreateObject to instantiate it.

> Regards



> > Greeting VBers,

> >    I had thought all the while that the New keyword in MTS is used
to
> > start
> > a new transaction context compared to CreateInstance which use the
> > current
> > or parent transaction context, is this right?

> >   I'm debugging a COM+ object which Required Transaction. A call to
a
> > method
> > will invoke other COM+ objects. Problems is this method (X) invoke
> > another
> > COM+ object (Y) using New, but the (Y) still working in the
transaction
> > context of (X)!

> >   So far my founding of this is by using the SQL Profiler to analyze
> > method
> > call to SQL Server. The method (X) will do a looping, which inside
is to
> > delete record on 1 table (handle by Y).

> > <--snipped-->
> > ObjX.clsX, Required Transaction
> > Sub mtdX()
> > Do While condition
> >   Set obj = New objY.clsY
> >   obj.mtdDelete record
> >   Set obj = Nothing
> > Loop

> >   COMSVCSLib.GetObjectContext.SetComplete
> > End Sub

> > ---------
> > ObjY.clsY, Required Transaction
> > Sub mtdDelete(record)
> >   Get existing record from SQL Server (SELECT * FROM table ...).
> >   Perform validation...
> >   Delete record.
> >   COMSVCSLib.GetObjectContext.SetComplete
> > End Sub
> > <--snipped-->

> > Case #1:If I use the ObjX.clsX.mtdX() to delete 1 record, no
problem.
> > Case #2:If I use the ObjX.clsX.mtdX() to delete more than 1 record;
1st
> > record deleted OK (which still rollback by ObjX due to 2nd record
> > timeout),
> > but 2nd record will timeout inside ObjY.clsY.mtdDelete() line where
it's
> > reading the record.

> > The duration to retrieve the record is max-out as shown in SQL
> > Profiler. So
> > such behaviour obviously indicate table locked by process when 1st
> > record
> > is deleted.

> > If the New keyword does indeed start a new transaction context, 2nd
> > record
> > deletion shouldn't be timeout (which probably due to locking).
Obviously
> > the whole process are still executing within a single transaction
hood.

> > Can someone show me how to start a transaction context in the COM+
> > object
> > using VB? Or is this a COM+ bug?

> > Currently we fixed this temporary by modifing the SQL statement to
> > retrieve
> > record in ObjY using locking hints (NOLOCK), which simply is not the
> > correct solution.
> > e.g. SELECT * FROM table WITH (NOLOCK)

> > TIA.

> > --
> > Yours sincerely,
> > Kelmen Wong
> > -----------

> > Sent via Deja.com http://www.deja.com/
> > Before you buy.

--
Yours sincerely,
Kelmen Wong
-----------

Sent via Deja.com http://www.deja.com/
Before you buy.



Fri, 17 Jan 2003 03:00:00 GMT  
 New and CreateInstance in COM+
Use CreateInstance to instantiate the component in the same activity as the
calling component and to inherit the transaction context, and use
CreateObject to instantiate the object in a new activity without getting the
parent context.


Quote:
> Mmm... OK, here's a scenario/requiment:

> We prepared a COM+ object which set to Required Tranx, as it will run
> in any Tranx Context either on it's own or in other caller's Context.
> So this design became as our standard protocol in creating COM+ object.

> But it come into a situation where this object will invoked by other
> COM+ object running in a Tranx Context, but need this object to execute
> in a separate Tranx Context. Is this possible without changing the
> tranx setting of the object using VB?



> > Don't use New to instantiate objects in MTS (except ADO objects).
> > New will create the objects outside the current context,
> > but it will not start a new transaction. The second component is
> > set as Requres so it takes the context of the transaction that
> created it.
> > To start a new transaction set the second object as Requires New, and
> > use CreateObject to instantiate it.

> > Regards



> > > Greeting VBers,

> > >    I had thought all the while that the New keyword in MTS is used
> to
> > > start
> > > a new transaction context compared to CreateInstance which use the
> > > current
> > > or parent transaction context, is this right?

> > >   I'm debugging a COM+ object which Required Transaction. A call to
> a
> > > method
> > > will invoke other COM+ objects. Problems is this method (X) invoke
> > > another
> > > COM+ object (Y) using New, but the (Y) still working in the
> transaction
> > > context of (X)!

> > >   So far my founding of this is by using the SQL Profiler to analyze
> > > method
> > > call to SQL Server. The method (X) will do a looping, which inside
> is to
> > > delete record on 1 table (handle by Y).

> > > <--snipped-->
> > > ObjX.clsX, Required Transaction
> > > Sub mtdX()
> > > Do While condition
> > >   Set obj = New objY.clsY
> > >   obj.mtdDelete record
> > >   Set obj = Nothing
> > > Loop

> > >   COMSVCSLib.GetObjectContext.SetComplete
> > > End Sub

> > > ---------
> > > ObjY.clsY, Required Transaction
> > > Sub mtdDelete(record)
> > >   Get existing record from SQL Server (SELECT * FROM table ...).
> > >   Perform validation...
> > >   Delete record.
> > >   COMSVCSLib.GetObjectContext.SetComplete
> > > End Sub
> > > <--snipped-->

> > > Case #1:If I use the ObjX.clsX.mtdX() to delete 1 record, no
> problem.
> > > Case #2:If I use the ObjX.clsX.mtdX() to delete more than 1 record;
> 1st
> > > record deleted OK (which still rollback by ObjX due to 2nd record
> > > timeout),
> > > but 2nd record will timeout inside ObjY.clsY.mtdDelete() line where
> it's
> > > reading the record.

> > > The duration to retrieve the record is max-out as shown in SQL
> > > Profiler. So
> > > such behaviour obviously indicate table locked by process when 1st
> > > record
> > > is deleted.

> > > If the New keyword does indeed start a new transaction context, 2nd
> > > record
> > > deletion shouldn't be timeout (which probably due to locking).
> Obviously
> > > the whole process are still executing within a single transaction
> hood.

> > > Can someone show me how to start a transaction context in the COM+
> > > object
> > > using VB? Or is this a COM+ bug?

> > > Currently we fixed this temporary by modifing the SQL statement to
> > > retrieve
> > > record in ObjY using locking hints (NOLOCK), which simply is not the
> > > correct solution.
> > > e.g. SELECT * FROM table WITH (NOLOCK)

> > > TIA.

> > > --
> > > Yours sincerely,
> > > Kelmen Wong
> > > -----------

> > > Sent via Deja.com http://www.deja.com/
> > > Before you buy.

> --
> Yours sincerely,
> Kelmen Wong
> -----------

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Fri, 17 Jan 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. kyduke(kyduke@yahoo.com)'s New Logic - New sorting, New paging method

2. Create new Roles on W2k3 com+ application

3. Where can i find Com+ Services type library or Component services com+ 1.0 for Win98

4. Serialize problem when using function from seperate assembly dll with createinstance()

5. Serialize problem when using function from seperate assembly dll with createinstance()

6. Activator.CreateInstance Issue??

7. Load Assembly /CreateInstance

8. Activator.CreateInstance

9. CreateInstance NullReferenceException

10. CreateInstance troubles.

11. Error from GetObjectContext.CreateInstance("...")

12. Error in loading DLL 48 when using CreateInstance

 

 
Powered by phpBB® Forum Software