View Single Post
  #1 (permalink)  
Old October 30th, 2003, 09:04 AM
arms2835 arms2835 is offline
Registered User
 
Join Date: Oct 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Compensating Resource Manager

We created a transactional file system object using some sample code from "Professional Windows DNA". We have an oracle DB, MSMQ, and files all participating in a distributed transaction. This works very well almost all of the time. Occasionally we get an error:
Error Number: -2147168239
Automation error

The error seems to occur on startup or after long idle periods. The Objectis in a server package with CRM enabled.

If we rerun one of these failed transactions it goes through fine.

Here is the code - It fails in the potentially infinite Do loop.

Private Sub RegisterCompensator()

    Dim sProgId As String
    Dim sDesc As String

    If gbDebug Then Dbg.Print "CFileSystemTrx.RegisterCompensator"

    'If we have already registered the compensator then exit the subroutine:
    If mbIsCompensatorRegistered = True Then Exit Sub

    sProgId = "FNFSO.CFileSystemCompensator"
    sDesc = "The compensator for CFileSystemTrx."

    'Register the componensator with the DTC. There is the possibility that
the
    'Compensator is in the process of recovering from a previous shutdown,
    'hence the error checking loop. We are only registering the compensator
    'for the commit and abort phases:
    On Error Resume Next
    Do
        moCrmLogControl.RegisterCompensator sProgId, sDesc, _
                                CRMREGFLAG_COMMITPHASE Or
CRMREGFLAG_ABORTPHASE
        DoEvents
    Loop Until Err.Number <> XACT_E_RECOVERYINPROGRESS

    'Was there an error registering the compensator?
    If Err.Number <> 0 Then GoTo ErrorHandler

    'Indicate that the compensator has been registered, so
    'subsequent calls to register the compensator abort:
    mbIsCompensatorRegistered = True

    Exit Sub
ErrorHandler:
    With Err
        Dim lNum As Long
        Dim lLNum As Long
        Dim sErr As String
        lNum = .Number
        sErr = .Description
        On Error GoTo 0
        RaiseCustomError "RegisterCompensator failed with the following " &
_
                "information: Error Number: " & lNum & _
                " Error Description: " & sErr
    End With

End Sub