Best
Practices of Component Design and What’s new in COM+ 1.5
Host: Mahesh ChandraMouli, Microsoft MVP, Wipro Technologies Ltd
June
27, 2003
Deepak_MS: Hi Friends!
Deepak_MS: Good Evening and welcome to MSDN India Expert Chat!
Deepak_MS: Today we have with us Mahesh ChandraMouli, he works at
Wipro and is also a Microsoft Most Valuable Professional..
Deepak_MS: He'll answer your questions on COM+ with special emphasis
on COM+ 1.5 which ships with Windows Server 2003
Deepak_MS: Over to you Mahesh
Deepak_MS: Here is the first question for you,
Deepak_MS: (anandm): My first question is tell me best practices when
moving from COM to COM+?
Deepak_MS: (anandm): Also what is a difference between MTS aware COM
component in VB 6.0 and COM+ component?
Mahesh: COM provides one way to write component based
applications
Mahesh: It is well known that the plumbing work required
to write COM components is significant and repetitive
Mahesh: COM+ provides a services infrastructure for components.
Mahesh: Here are some of the best practices that I want
to share:
Mahesh: Do not mix declarative and imperative transactions.
(Ideally, do not use imperative transactions at all.)
Mahesh: If a component can be called by multiple threads
concurrently, choose an appropriate synchronization setting to ensure
thread safety.
Mahesh: Don't run long running Transactions
Mahesh: Minimize the amount of client-specific state information
that a serviced component holds.
Mahesh: 2.Supply values for ApplicationNameAttribute,
ApplicationIDAttribute, and ApplicationActivationAttribute for an
assembly that implements a serviced component.
Mahesh: If you're using pooling, implement CanBePooled,
Activate, and Deactivate. Do not place initialization code in the
constructor unless it needs to be performed only once.
Mahesh: Use an appropriate isolation level to maximize
throughput while maintaining consistency
Mahesh: In COM+ 1.5 you have an option of configurable
isolation leve;
Mahesh: Use JIT activation with AutoCompleteAttribute
wherever possible
Deepak_MS: (PinnacleArun): Hi Deepak, I had developed COM+ 1.0 based
components in VB6.0 , Is it compatible with Com+1.5 ? Because I faced
a lot of problems when upgrading my MTS based components to COM+1.0.?
Mahesh: Yes you can deploy your COM+1.0 components in
COM+1.5.
Deepak_MS: (Praba): Can you explain about Configurable Isolation Levels?
Mahesh: In COM+ 1.5 you can configure your transaction's
isolation level. On your COMPONENT SERVICES MMC you can find options
of Seriliazable, ReadCommited, ReadUncommited and other options
Mahesh: You can choose any of these options
Mahesh: COM+ tells the Distributed Transaction Coordinator
(DTC) to start a transaction and bind it to the component before any
class code is executed.
Mahesh: When making a transactional method call against
a database from a COM+ 1.0 (or MTS) component, DTC sets the default
isolation level to SERIALIZABLE to promote the highest data protection
but non-existent concurrency.
Mahesh: The problem is that under heavy load with many
transactions hitting the same database resources concurrently, a higher
isolation level means serialized data access and the requests taking
longer to process.
Mahesh: DTC timeouts
Mahesh: So this has been rectified in COM+1.5 using configurable
isolation levels
Deepak_MS: (Praba): which isolation model is preferred for COM+ 1.5
applications?
Mahesh: it depends on your application
Mahesh: the higher the isolation, the longer it takes
to process a transactional operation due to less concurrency between
transactions.
Mahesh: be careful on this issue.. Be careful if calling
from a COM+ 1.5 to a COM+ 1.0 system. A 1.0 component uses SERIALIZABLE
by default and if a called 1.5 component uses a lower isolation level,
the 1.0 component will not be instantiated.
Deepak_MS: (Bobs): The default level is Serializable. But is there
any way this can be changed?
Mahesh: you can change, goto the COMPONENT SERVICES MMC
--> right click-->
Mahesh: properties you will see a dropdown
Mahesh: which consist list of isolation level, choose
a particular isolation level for that component this can't be done
in COM+1.0 it is possible only in COM+1.5
Deepak_MS: (COM): I have single database to connect, would it be faster
to manage transactions on my own or through COM+ DTC?
Mahesh: I am listing down some of the cool features in
COM+1.5
Mahesh: Avoid going for COM+ as much as u can. If u can
handle using database transactions it is fine, when you are going
for two phase commit COM+ is a must
Mahesh: COM+ is a overhead, there will be a small performance
hit
Deepak_MS: Ok Mahesh could you shed some light on Transactions without
components..
Mahesh: this is one of the interesting changes in COM+1.5.
you no longer need to inherit from ServicedComponent.
Mahesh: Here is an article i have written to know more
about Services Without COmponents take a look at this article
Mahesh: Also, here are some of the cool features of Com+1.5
Mahesh: 1. Application pooling
Mahesh: You can achieve good scalability by pooling your
components. However, an application configured to run as a service
cannot take advantage of application pooling.
Mahesh: 2. Application re-cycling
Mahesh: Problem: The performance of most applications
degrades over time Third-party code of uncertain quality, Memory leaks
Mahesh: You can recycle your application using the COMPONENT
SERVICES MMC configurations:
Mahesh: there are different configurations such as Lifetime
Limit, Activation Limit, Memory Limit etc. These are configurable
parameters
Mahesh: 3. COM+ Applications as Windows service
Mahesh: No code required! Just run application as NT service
checkbox in the Component Services MMC, to activate as a service
Mahesh: 4.Process Dump mechanism
Mahesh: Non-invasively, by right-clicking on the application
in the Running Process folder, and then clicking Dump. This will immediately
take a dump of that application process, and the process itself (lifetime)
is unaffected.
Mahesh: 5. COM+1.5 as WebServices
Mahesh: Go to the Component Services MMC, from the Activation
tab of an application's property sheet, find the SOAP group box. By
merely enabling the check box, and specifying a new or existing IIS
virtual directory name, that COM+ application can now function as
a hosted SOAP Service.