IResourceManagerFactory::Create

This method is used to create a resource manager object.

HRESULT Create (
GUID *
pguidRM,
TCHAR *
pszRMName,
IResourceManagerSink *
pIResMgrSink,
IResourceManager **
ppResMgr);

Parameters

pguidRM [in]
A UUID that uniquely identifies this resource manager.

pszName [in]
A string name that identifies this resource manager.

pIResMgrSink [in]
Pointer to the resource manager’s IResourceManagerSink interface. The resource manager developer must implement the TMDown method on this interface.

ppResMgr [out]
Pointer to the pointer to the IResourceManager interface on the resource manager object.

Return Values

S_OK
Success.

E_NOINTERFACE
Requested interface is not available.

E_OUTOFMEMORY
Unable to allocate memory.

XACT_E_TMNOTAVAILABLE
Unable to connect to the transaction manager.

XACT_E_CONNECTION_DOWN
Connection with the transaction manager was lost.

XACT_E_CONNECTION_REQUEST_DENIED
The transaction manager refused to accept a connection.

XACT_E_DUPLICATE_GUID
There is already a resource manager connected to the transaction manager with the same GUID as was passed in pguidRM.

E_UNEXPECTED
An unexpected error has occurred.

Comments

The resource manager object represents the connection between the resource manager and the transaction manager. The resource manager object supports the IResourceManager interface that resource manager use to enlist in transactions and to perform transaction recovery.

A resource manager typically invokes the IResourceManager::Create method when the resource manager first starts. By doing this the resource manager registers itself with the transaction manager. The resource manager retains the resource manager object until it no longer needs the services of the transaction manager. It then releases IResourceManager interface. This ends the connection with the transaction manager. A resource manager typically retains the transaction manager connection until the resource manager stops.

If the connection between the transaction manager and the resource manager fails, the MS DTC proxy invokes the resource manager’s IResourceManagerSink::TMDown method. This callback informs the resource manager that its transaction manager connection has failed. The resource manager must invoke the IResourceManagerFactory::Create method again to reregister with the transaction manager.