-
Event Handler Issue
I am attempting to write an event handler to catch when Biztalk places an item in it’s suspended queue. My code runs without generating any errors, but does not respond to the event. I have looked at several books and samples but have not found the solution. Does anyone have any thoughts on what the problem might be?
Thanks
Brad
Code:
Private WithEvents sink As New WbemScripting.SWbemSink
Private objWbemServices As WbemScripting.SWbemServices
Private Sub SetupEvent()
Dim objnet As New IWshRuntimeLibrary.IWshNetwork_Class()
Dim wbemLocat As New WbemScripting.SWbemLocator()
Dim objWbemEventSource As WbemScripting.SWbemEventSource
Dim objWbemObject As WbemScripting.SWbemObject
Dim strMachineName As String
Try
' local machine name
strMachineName = objnet.ComputerName
' register the sink to receive SuspendedQueue hits
objWbemServices = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strMachineName & "\Root\MicrosoftBizTalkServer")
objWbemServices.Security_.Privileges.Add(WbemScripting.WbemPrivilegeEnum.wbemPrivilegeSecurity)
objWbemServices.ExecNotificationQueryAsync(sink, "Select * from DocSuspendedEvent")
Catch eException As System.Exception
‘error handling omitted
Finally
wbemLocat = Nothing
objWbemEventSource = Nothing
objWbemObject = Nothing
End Try
End Sub
Private Sub sink_OnObjectReady(ByVal objWbemObject As WbemScripting.SWbemObject, ByVal objWbemAsyncContext As WbemScripting.SWbemNamedValueSet) Handles sink.OnObjectReady
‘the event handler - details omitted
End Sub
-
Do you raise the event OnObjectReady?
-
I am successfully getting documents into the Suspended Queue, which triggers the DocSuspendedEvent that this is supposed to be watching. According to the documentation the sink OnObjectReady event fires at this time.
I know this is happening because the VB6 example that came with Biztalk catches it. Unfortunately that example is not suitable for my purpose and doesn't run after upgrading to .net using the wizard. From the other articles I've seen I think this code is really close, but after a week I still don't know what's wrong with it.
Brad