Click to See Complete Forum and Search --> : MTS Advice Sought


CLW
May 2nd, 2001, 07:16 PM
Here is the scenario:

I am writing a web application, and need to make sure that I can deploy it
on NT4/IIS4, or W2K/IIS5, or win95/98/me/PWS. I will optimize for running
the app on W2K/IIS5.

I have followed Microsoft DNA (though not strictly in some cases), and
created DAL, and BLL, with ASP being PL.

My DAL is basically a number of classes that provide accesses to stored
procs (for SQL Server), and my BLL calls the stored procs provided by the
DAL. Now in terms of transactions, I do not need to use MTS because I have
yet to encounter a situation where a stored proc on a sqlserver couldn't
encapsulate the entire transaction or handle the business logic. Now I would
like to use MTS because it is capable of doing resource pooling for me. In
particular, the DAL and BLL components would be created and destroyed as
required by the PL, MTS can cache and preserve frequently used components,
thus optimizing performance.

Now here are the stumbling blocks:

(1) W2K uses COM+ rather than MTS, and a different type library is used. So
would components created for NT4 even run on COM+ under W2K, or vice versa,
can an COM+ component compiled on W2K run on NT4 MTS?

(2) Win95/98/Me do not have MTS at all, and the obviously question is,
whether an MTS enabled component can run at all?

(3) Note that I have marked all of my components to be able to participate
MTS transaction, but does not require a transaction (or new transaction)
because stored procs are completely self encapsulated when it comes to
transaction or business logic. Should I instead mark them as Not An MTS
object at all?

(4) I heard (unsubstantiated) news that IIS5 act as MTS server as well, and
thus I do not need to install MTS packages (as in not having to create an application in COM Service, and register the COM dlls). Is that true?

Thanks in Advance

Cakkie
May 3rd, 2001, 02:40 AM
I'm not sure i'll be able to anser them all, but i'll give it a shot

1) MTS components (NT4) can be used for COM+ (2K). The other way isn't always true. This is because there are some functionalities that COM+ has and MTS doesn't. However, if you don't use them, you should be able to port them to MTS

2) Win95/98/Me don't have anything like COM+ or MTS. Those machines cannot operate as an application server. However, they can use the components just as if they were regular components. Again, this is only true if you don't use any COM+/MTS functionality. Also, the main goal of MTS/COM+ would be lost (centralize components). You could also use the components via DCom, in this case the components are created on the target computer (the one where they were compiled), this way you are actually using them the way you should.

3) If you handle your transactions yourself in SQL server (or wherever) you don't need the transaction services. I would advice to turn it off, because if for one reason or anther a transaction is started by MTS/COM+, this might give unwwanted results (Like the stored procedure doing a commit and MTS a roolback).

4) No, IIS5 does not act as MTS. Besides, COM+ is more optimized for Win2k than MTS, so you should use COM+ on win2k in stead of MTS.

Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

CLW
May 3rd, 2001, 07:57 AM
I really appreciate the help, as I have found rather difficult to obtain information on this matter.

There is one thing that I am wondering if you could clarify regarding running the component on w95/98/me. Under MTS/COM+, I have to set a reference to mtxas.dll. Are you saying that I do not need to set the reference if I do not require any of the MTS transaction capability? Or you meant that even if I set references to that dll, since I won't be calling any of the methods (such as getcontext.createinstance), I would be able to run the component (compiled with a reference to mtxas.dll) on w95/98/me computers?

TIA

CW

Cakkie
May 3rd, 2001, 09:43 AM
It depends on how you are using the components.
If you don't use the anything like getcontext.creatinstance, or setabort or setcomplete or whatever, you don't need to refference the mtxas.dll. The client (whether 95/98/me/nt or 2000) doesn't even need to know what files are refferenced to, because the actual execution is done by the application server (NT runing MTS ot 2000 running COM+). It just uses the dlls to get the typelibraries of the components.
If you are planning on using the components outside MTS/COM+, you do need the refferences.
Let me give an example.
Say you have a component that connects to a SQL server and alters some data using ADO.
If you use that component as a MTS/COM+ component, the application server needs ADO, and the application server will connect to the SQL server, not the client, so the client doesn't need ADO.
However, if hte component isn't used as MTS/COM+ component, the client makes the connection to the SQL server, and so the client needs ADO.

Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

dfwade
May 3rd, 2001, 12:43 PM
I have read your post and the responses and I would like to point out a couple of common misunderstandings about MTS. This are little known facts about MTS that may influence your decision on using it.

1.) With VB you can not use object pooling, so no benefits there
2.) ODBC 3.0 provides database connection pooling without resorting to MTS.

Unless you have a situation that requires a transaction to be handled by com, because you are doing more than writing to a single datasource, ie some of your transaction is going to one server and some is going to another and you have to create a message for the transaction to be complete. The ACID rules for a tranaction are misinterpretted a great deal. From your comments you do not seem to require this and your benefits from implementing MTS seem marginal, especially since you will have to code to a common denominator of Classic COM and MTS, rather than COM+

For Detailed information look here:
http://www.vb2themax.com/HtmlDoc.asp?Table=Articles&ID=80

CLW
May 4th, 2001, 12:03 AM
Thanks for the link to that article.

Now you have mentioned that VB COM objects can not take advantage of object pooling capability of MTS. I am wondering whether you can provide more details on this one. I have always been told (and read myself) many times that the advantage of MTS (or COM+) is to (1) transaction support (2) object pooling. As you have gathered, I really do not require transaction support of MTS since I code all the businesss logic, and transactions in stored procedures (even in multi-data source environment, I always use distributed transaction via SQL Server, not MTS). The only reason that I am thinking of using MTS is to utilize object pooling since I tend to write small and fast objects (and thus client applications need to create and destroy them very often).

I am aware that ODBC drivers have connection pooling capabilities built in. However, when connecting to SQL Server, I have often been advised to use SQLOLEDB as provider, thus requiring me to specify a DSN-less connection string. If that's the case, do I still get connection pooling functionality? Or am I supposed to use OLEDB for ODBC as provider, and rely on ODBC driver for connection pooling?

TIA
CLW

Cakkie
May 4th, 2001, 02:07 AM
Object pooling with VB components is not possible. This is because VB is single threaded. Object pooling requires multi threading. C++ is multithreaded (or capable of doing so), so C
++ components can be pooled.

The other thing about connection pooling has absolutely nothing to do with COM+. It's something that's just there. No, you do not need to use ODBC to do connection pooling. You can use any OLEDB provider. It's OLEDB who manages the connections. Connection pooling is only possible for connections within the same security context. In human language, this means if you always connect to the same database, using the same username and password and other stuff (just say the same connectionstring), connection pooling will be done automatically. I've heard there is a way to configure connection pooling (like limiting the number of connections), but I haven't yet found out how.

Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

CLW
May 4th, 2001, 02:29 AM
Again thanks for the invaluabe advice.

As to connection pooling, my biggest problem has always been the inability to limit the maximum number of connections (and unfortunately, lots of ISPs put a maximum connections to DB allowable in their SLA). Thanks for clarifying that connection pooling does not require ODBC drivers though. I have implemented my own method to limit maximum number of connections. However, if you ever become aware of a way to limit the maximum number of connections, please let me know.

Thanks

CLW