This chapter contains the following topics:
Section 6.1, "Understanding COM Connector Guaranteed Events"
Section 6.2, "Setting Up the COM Connector for Guaranteed Events"
Section 6.3, "Implementing JD Edwards EnterpriseOne Interfaces"
Section 6.4, "Registering EventSink for Persistent Subscription"
The COM connector events solution uses the Microsoft COM+ Events Service. COM+ Events Loosely Coupled Events, which matches and connects publishers and subscribers, is part of the Microsoft Windows Component Services. The EventClass is a COM+ component that contains interfaces and methods that are used by the publisher to initiate events. The EventClass manages the connection between publisher and subscribers. The EventClass.dll, which contains the IOWEvent interface, is provided. The COM servers and COM clients must implement this interface so that when an event is initiated, this interface is called by the COM+ Events Service and the implementation is executed. The implementation decides what the delivered event and the event data should do. This implementation is COM server or COM client specific.
To support guaranteed event delivery for JD Edwards EnterpriseOne, the COM connector uses XML. This illustration shows the COM connector architecture for guaranteed events:
Figure 6-1 COM connector architecture-guaranteed event delivery
Note:
You should have a basic understanding of the COM+ Events Service.COM+ events supports Z events, real-time events, and XAPI events. COM+ Events Service is not dependent on JD Edwards EnterpriseOne setup for event generation.
See Also:
Microsoft MSDN, http://www.msdn.microsoft.com
.
"Using Guaranteed Events" in the JD Edwards EnterpriseOne Tools Interoperability Guide.
"Using Guaranteed Real-Time Events" in the JD Edwards EnterpriseOne Tools Interoperability Guide.
"Using Guaranteed XAPI Events" in the JD Edwards EnterpriseOne Tools Interoperability Guide.
This section provides an overview of the process for setting up the COM connector to receive guaranteed events.
Setting up the COM connector includes setting up security and setting up the identity as an interactive user. After you install and set up the COM connector, you set up a DCOM server on a JD Edwards EnterpriseOne server machine. DCOM enables COM objects in a distributed environment. To ensure that the interoperability client works properly, you must set up DCOM for both a server environment and for a client environment. You also register the COM connector components, subscribe to events, and log errors and messages.
Use these steps to install and set up the COM connector:
Note:
All of the COM connector required files will be installed with the JD Edwards EnterpriseOne client. If you have the JD Edwards EnterpriseOne client, ignore Step 1 and start with Step 2. If you do not have the JD Edwards EnterpriseOne client and you want to set up the COM connector on a third-party machine, start with Step 1.Copy these files from the JD Edwards EnterpriseOne server (system\bin32) to a directory on the desired machine. For example, copy the files in c:\program files\JDEdwards to a non-JD Edwards EnterpriseOne client machine.
JDECOMConnector2.exe
JDECOMMN.dll
callobject.dll
comlog.dll
EventManager.dll
OneWorldInterfaceTx.dll
xmlinterop.dll
jdel.dll
jdethread.dll
jdeunicode.dll
ustdio.dll
icuil8n.dll
jdeinterop.ini to c:\(root directory)
checkver.exe
ICUUC.dll
Icu\data\*.*
IXXML4C2_3.dll
EventClass.dll
EventListener.dll
EventHandler.dll
ClientService.dll
Create a new directory Icu\data\ on the machine where the COM server is located.
Copy all of the files from the JD Edwards EnterpriseOne server in folder system\Locale\xml\*.* into Icu\data\. Create a new system variable, ICU_DATA, in the environment variables of the system properties and specify the path to the Icu\data\ as the value.
Use these steps to register the COM Connector:
Run this command:
c:\programfiles\JDEdwards\JDECOMConnector2.exe /RegServer
Go to c:\programfiles\JDEdwards\ Or c:\b9\system\bin32 and run these commands:
regsvr32 EventManager.dll regsvr32 EventClass.dll
Create the JDEinterop.ini file by setting the JD Edwards EnterpriseOne server and port values to the JD Edwards EnterpriseOne application server with which you want the COM server to communicate.
The COM server is now ready.
Use these steps to set up security on the COM server:
From the Start menu, select Run.
Enter Dcomcnfg.exe.
On Distributed COM Configuration Properties, click the Default Security tab.
Click the Edit Default Button in Default Access Permissions group.
The Registry Value Permissions form appears. Some entries might already be present.
On Registry Value Permissions, click Add.
On Add Users and Groups, select the appropriate domain from the List Names From option.
Click Everyone, and then click Add.Type of access should be Allow Access.
Click OK.
No setup is required for default configuration permissions.
Use these steps to set up the identity as an interactive user:
Run DCOMCnfg.
On Distributed COM Configuration Properties, select JDECOMConnector2, and then click Properties.
On JDECOMConnector2Properties, click the Identity tab, and then select the interactive user option.
Click Apply to apply the change.
Note:
Every time you register the connector, you must set up the identity as an interactive user. If you copy the JDECOMConnector2.exe using Explorer, Explorer reruns the registration, and you must set up the identity as an interactive user.To use Callbacks (Connection Points) with the COM solution, repeat these steps for setting up the identity as an interactive user on the COM client machine. Most of the shipped examples use Callbacks and require that you open the security on the client machine.
Use these steps to set up DCOM for a client environment:
From a DOS prompt on the DCOM client machine, run jdecomconnector2.exe /RegServer.
At the prompt, enter oleview.exe.
From the menu bar, select oleview.
Click View and select Expert Mode.
In the oleview window under Object Classes, double-click All Objects, and wait for all objects to appear.
Under All Objects, find and click Connector Class.
Click the Implementation tab on the right-side panel, and then click the local server and remove anything that appears in the editing window.
On the Activation tab, select the Launch as Interactive User option.
In Remote Machine Name, enter the COM server machine name.
Repeat steps 5 through 8 for MathNumeric Class.Start the DCOM client application.
Start the DCOM client application.
So that subscribers can find an event class and subscribe to it, the JD Edwards EnterpriseOne event class must be registered with COM+. In addition, COM+ requires a type library that describes the event interface and methods so that subscribers and publishers can be properly matched and connected. The type library must reside in or be accompanied by a self-registering DLL.
To register the JD Edwards EnterpriseOne Events Class with COM+ Services, you must:
Add a new COM+ application for the JD Edwards EnterpriseOne event class.
Install the JD Edwards EnterpriseOne event class.
Note:
Before you register the JD Edwards EnterpriseOne Event Class with COM+ Services, set up the COM server. The COM server can be set up on either a JD Edwards EnterpriseOne machine or a non-JD Edwards EnterpriseOne machine (third-party machine), or both.See Also:
The COM connector supports event subscriptions from JD Edwards EnterpriseOne (JD Edwards EnterpriseOne server and Transaction server). The COM connector connects to the JD Edwards EnterpriseOne Transaction server to receive its subscribed events.
This section provides an overview about implementing the JD Edwards EnterpriseOne interface and discusses how to:
You must develop an object that implements the IOWEvent interface. For further discussion and for code samples in this document, the name EventSink is used as the object name. The object that you develop to implement the IOWEvent can have a different name. EventSink implements the IOWEvent interface and the method within the interface, and then consumes the JD Edwards EnterpriseOne event. The EventSink implementation is client specific. EventSink receives the event from JD Edwards EnterpriseOne by implementing the interface specified in EventClass.
This code outline shows how to develop an EventSink component:
Option Explicit Implements IOWEvent Public Event OneWorldEvent(ByVal EventName As String, ByVal Data As String) Public Sub IOWEvent_OneWorldEvent(ByVal EventName As String, ByVal Data As String) '// Add code specific to the client implementation here RaiseEvent OneWorldEvent(EventName, Data) End Sub
This list outlines the steps for you to follow to use the EventManager library and MessageHandler Interface to subscribe to events.
Log on to the connector. Successful logon returns an access number.
Create the EventSink object.
Create the MessageHandler object.
Call methods on the MessageHandle for Subscribe, Unsubscribe, GetTemplate, and GetEventList for the respective event.
To keep the session alive and not time out from receiving events, call the UpdateOutBoundSessionTime method on the connector interface.
This method updates the user session time to the current time.
To subscribe to the events as persistent, register VB EventSink in the COM+ Component Services and add the subscription for the EventClass.
This sample code is for creating a COM+ component named EventSink.dll. EventSink implements the EventClass interface IOWEvent(). You can use a name other than EventSink.
This code illustrates how to create a COM+ component:
Option Strict Off Option Explicit On <System.Runtime.InteropServices.ProgId ("OneWorldTransientEventSink_NET.OneWorldTransientEventSink")> Public Class OneWorldTransientEventSink Implements EventClass.IOWEvent Public Event OneWorldEvent(ByVal EventName As String, ByVal Data As String) Public Sub IOWEvent_OneWorldEvent(ByVal EventName As String, ByVal Data As String) Implements EventClass.IOWEvent.OneWorldEvent Dim flsObject As New Scripting.FileSystemObject Dim varEventFile As Scripting.TextStream Dim strEventFile As String strEventFile = "C:\temp\eventDataPer.xml" 'UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword= "vbup1041"' If Dir(strEventFile) = "" Then varEventFile = flsObject.CreateTextFile(strEventFile, False, False) Else varEventFile = flsObject.OpenTextFile(strEventFile, Scripting.IOMode.ForWriting, False) End If varEventFile.WriteLine(Data) varEventFile.Close() RaiseEvent OneWorldEvent(EventName, Data) End Sub End Class
This sample code logs on to the COM connector, creates the MessageHandler object, and performs Subscribe, Unsubscribe, GetTemplate, and GetList. Before executing the subscriber, use the Regsvr32 command to register COMConnector.dll.
This code sample shows logging on to the COM connector:
Option Strict Off Option Explicit On Friend Class frmLogin Inherits System.Windows.Forms.Form Public bLoginEnv As Boolean Private Sub cmdCancel_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdCancel.Click 'set the global var to false 'to denote a failed login bLoginEnv = False Me.Hide() End Sub Private Sub cmdOK_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdOK.Click 'check for correct password If txtUserName.Text = "" Or txtenvironment.Text = "" Then bLoginEnv = False MsgBox("Must Enter User Name and Environment to continue") Else bLoginEnv = True Me.Hide() End If End Sub End Class
This code sample shows creating the message handler:
Option Strict Off Option Explicit On Module Common Dim conn As New JDECOMCONNECTOR2Lib.Connector Dim connRole As JDECOMCONNECTOR2Lib.IConnector2 'Dim messageHandler As New messageHandler 'Dim mHandlerInterface As ImessageHandler Dim lngAccessNumber As Integer Public Sub comm_Initialize() connRole = conn On Error GoTo errorHandler frmLogin.DefInstance.bLoginEnv = False frmLogin.DefInstance.Show() While Not frmLogin.DefInstance.bLoginEnv System.Windows.Forms.Application.DoEvents() End While lngAccessNumber = connRole.E1_Event_Login(frmLogin. DefInstance. txtUserName.Text, frmLogin.DefInstance.txtPassword.Text, frmLogin. DefInstance.txtenvironment.Text, frmLogin.DefInstance.txtrole.Text) 'Debugging Purpose 'lngAccessNumber = connRole.E1_Event_Login("JP6849777", "PASSWORD", "TDEVNIS2", "*ALL") connRole = conn Exit Sub errorHandler: MsgBox("Login Failed. You can't Use this Application") End Sub ' NOTE: the code in this module is particular to this prototype. ' Different code is used in a production version to send messages to ' JD Edwards EnterpriseOne using JD Edwards communication protocols. Public Sub SendSubscriptionToOneWorld(ByRef eventName As String, ByRef oneworldevent As EventClass.IOWEvent, ByRef mode As Integer) 'mHandlerInterface.SubscribeEvent lngAccessNumber, conn, eventName, oneworldevent, mode On Error GoTo errorHandler connRole.E1_Event_Subscribe(lngAccessNumber, oneworldevent) Exit Sub errorHandler: MsgBox("Subscirbe Method Failed. You can't Use this Application") End Sub Public Sub SendUnSubscribeToOneWorld(ByRef eventName As String, ByRef oneworldevent As EventClass.IOWEvent, ByRef mode As Integer) On Error GoTo errorHandler 'mHandlerInterface.UnSubscribeEvent lngAccessNumber, conn, eventName, oneworldevent, mode connRole.E1_Event_UnSubscribe(lngAccessNumber) Exit Sub errorHandler: MsgBox("UnSubscirbe Method Failed. You can't Use this Application") End Sub Public Sub SendLogoffToOneWorld() 'mHandlerInterface.SubscribeEvent lngAccessNumber, conn, eventName, oneworldevent, mode On Error GoTo errorHandler connRole.E1_Event_Logoff(lngAccessNumber) Exit Sub errorHandler: MsgBox("LogOff Method Failed. Terminate ComConnector Process and End the Application") End Sub Public Sub getEventListFromOneWorld(ByRef eventList As String) On Error GoTo errorHandler 'mHandlerInterface.GetEventList lngAccessNumber, conn, eventList eventList = connRole.E1_Event_GetEventList(lngAccessNumber) Exit Sub errorHandler: MsgBox("GetEventList Method Failed. You can't Use this Application") End Sub Public Sub getEventTemplateFromOneWorld(ByRef eventName As String, ByRef eventTemplate As String) On Error GoTo errorHandler 'mHandlerInterface.GetEventTemplate lngAccessNumber, eventName, conn, eventTemplate Exit Sub errorHandler: MsgBox("GetEventTemplate Method Failed. You can't Use this Application") End Sub End Module
This code sample shows event subscription and unsubscribe:
Option Strict Off Option Explicit On <System.Runtime.InteropServices.ProgId("SubscriptionManager_NET. SubscriptionManager")> Public Class SubscriptionManager 'Private Const m_OneWorldEventCLSID = "{1E645180-6C93-4704-85C6- 57775E2ED2FC}" Private m_SubscribedEvents As Collection 'UPGRADE_NOTE: Class_Initialize was upgraded to Class_Initialize_ Renamed. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/ redirect.htm?keyword="vbup1061"' Private Sub Class_Initialize_Renamed() m_SubscribedEvents = New Collection comm_Initialize() End Sub Public Sub New() MyBase.New() Class_Initialize_Renamed() End Sub Public Sub GetEventList(ByRef eventList As String) getEventListFromOneWorld(eventList) End Sub Public Sub Logoff() SendLogoffToOneWorld() End Sub Public Sub CreateTransientSubscription(ByRef eventName As String, ByRef oneworldevent As EventClass.IOWEvent) SubscribeToOneWorldEvent(eventName, oneworldevent, 0) End Sub Public Sub CreatePersistentSubscription(ByRef eventName As String, ByRef oneworldevent As EventClass.IOWEvent) SubscribeToOneWorldEvent(eventName, oneworldevent, 1) End Sub Public Sub RemoveTransientSubscription(ByRef eventName As String, ByRef oneworldevent As EventClass.IOWEvent) UnSubscribeToOneWorldEvent(eventName, oneworldevent, 0) End Sub Public Sub RemovePersistentSubscription(ByRef eventName As String, ByRef oneworldevent As EventClass.IOWEvent) UnSubscribeToOneWorldEvent(eventName, oneworldevent, 1) End Sub Public Sub GetEventTemplate(ByRef eventName As String, ByRef eventTemplate As String) getEventTemplateFromOneWorld(eventName, eventTemplate) End Sub Public Sub SubscribeToOneWorldEvent(ByRef eventName As String, ByRef oneworldevent As EventClass.IOWEvent, ByRef mode As Integer) 'Private Function SubscribeToOneWorldEvent(EventName As String) As Boolean ' we've already subscribed if the subscription is in our list Dim alreadySubscribed As Boolean 'UPGRADE_WARNING: Couldn't resolve default property of object CollectionContainsString(). Click for more: 'ms-help: //MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"' alreadySubscribed = (CollectionContainsString (m_SubscribedEvents, eventName) = True) ' now do the right thing... If (alreadySubscribed = False) Then ' this instance of the COMConnector has not seen this ' event before, so add it to our list... m_SubscribedEvents.Add((eventName)) ' ...and go ahead and subscribe to the event from JD Edwards EnterpriseOne SendSubscriptionToOneWorld(eventName, oneworldevent, mode) End If 'SubscribeToOneWorldEvent = alreadySubscribed End Sub 'UPGRADE_NOTE: str was upgraded to str_Renamed. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1061"' Private Function CollectionContainsString(ByRef col As Collection, ByRef str_Renamed As String) As Object Dim colItem As Object For Each colItem In col 'UPGRADE_WARNING: Couldn't resolve default property of object colItem. Click for more: 'ms-help: //MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"' If (colItem = str_Renamed) Then 'UPGRADE_WARNING: Couldn't resolve default property of object CollectionContainsString. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"' CollectionContainsString = True Exit Function End If Next colItem 'UPGRADE_WARNING: Couldn't resolve default property of object CollectionContainsString. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"' CollectionContainsString = False End Function Public Sub UnSubscribeToOneWorldEvent(ByRef eventName As String, ByRef oneworldevent As EventClass.IOWEvent, ByRef mode As Integer) Dim alreadySubscribed As Boolean 'alreadySubscribed = (CollectionContainsString (m_SubscribedEvents.Item, eventName)) ' now do the right thing... 'If (alreadySubscribed = True) Then ' this instance of the COMConnector has not seen this event before, so ' remove it from the list... alreadySubscribed = (RemoveFromCollection (m_SubscribedEvents, eventName)) If (alreadySubscribed = False) Then MsgBox("Event Not Subscribed") Else 'm_SubscribedEvents.Remove () ' ...and go ahead and subscribe to the event from JD Edwards EnterpriseOne SendUnSubscribeToOneWorld(eventName, oneworldevent, mode) End If ' End If End Sub 'UPGRADE_NOTE: str was upgraded to str_Renamed. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1061"' Private Function RemoveFromCollection(ByRef col As Collection, ByRef str_Renamed As String) As Object Dim colItem As Object Dim count As Short count = 0 For Each colItem In col count = count + 1 'UPGRADE_WARNING: Couldn't resolve default property of object colItem. Click for more: 'ms-help: //MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"' If (colItem = str_Renamed) Then col.Remove(count) 'UPGRADE_WARNING: Couldn't resolve default property of object RemoveFromCollection. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"' RemoveFromCollection = True Exit Function End If Next colItem 'UPGRADE_WARNING: Couldn't resolve default property of object RemoveFromCollection. Click for more: 'ms-help: //MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"' RemoveFromCollection = False End Function End Class
Subscriber is the GUI that gets the EventsList, EventTemplate, Subscribe, and Unsubscribe. Subscriber is built as a VB executable. Typical usage is to get the EventList first, which populates the list of options with the events that are supported by the JD Edwards EnterpriseOne server. Select the event that needs to be subscribed from the JD Edwards EnterpriseOne server and the type of subscription. Click Subscribe to add a Subscription, or click Unsubscribe to unsubscribe from the JD Edwards EnterpriseOne server. The Subscribed events and the Received events are in separate boxes. The received event is displayed in the window on the right. The event received can be integrated with BizTalk by choosing the Enable BizTalk Integration option. You should have previously set up BizTalk; if not already installed, install the BizTalk Server 2000 Developer. If the Module 1 tutorial in the BizTalk Server documentation runs properly, then the BizTalk Server is properly installed. Before building the subscriber, you should use the Regsvr32 command to register EventSink.dll and COMConnector.dll.
This code sample is for the GUI and the control buttons on the GUI. This code should be built along with the BizTalk.cls, after registering the COMConnector.dll and MyEventSink.dll.
VERSION 5.00 Object = "{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}#1.1#0"; "shdocvw.dll" Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx" Begin VB.Form MainForm Caption = "Subscriber Client" ClientHeight = 7470 ClientLeft = 3555 ClientTop = 2820 ClientWidth = 11655 LinkTopic = "Form1" ScaleHeight = 7470 ScaleWidth = 11655 Begin VB.Frame grpSubscribedEvents Caption = "Subscribed Events" Height = 2895 Index = 1 Left = 120 TabIndex = 17 Top = 2160 Width = 2775 Begin VB.CommandButton Command1 Caption = "Clear" Height = 375 Left = 4560 TabIndex = 18 Top = 2280 Width = 975 End Begin MSComctlLib.ListView lvwSubscribedEvents Height = 1695 Left = 120 TabIndex = 19 Top = 360 Width = 2535 _ExtentX = 4471 _ExtentY = 2990 View = 2 LabelWrap = -1 'True HideSelection = -1 'True _Version = 393217 ForeColor = -2147483640 BackColor = -2147483643 BorderStyle = 1 Appearance = 1 NumItems = 2 BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A- 00C0F0283628} Key = "colEventName" Text = "Event Name" Object.Width = 2540 EndProperty BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A- 00C0F0283628} SubItemIndex = 1 Key = "colData" Text = "Data" Object.Width = 6174 EndProperty End End Begin VB.CommandButton btnGetEventTemplate Caption = "Get Template" Height = 375 Left = 3720 TabIndex = 14 Top = 120 Width = 1455 End Begin VB.CommandButton btnGetEventList Caption = "Get Event List" Height = 375 Left = 600 TabIndex = 13 Top = 120 Width = 1455 End Begin SHDocVwCtl.WebBrowser wbEventData Height = 6375 Left = 6240 TabIndex = 12 Top = 360 Width = 5175 ExtentX = 9128 ExtentY = 11245 ViewMode = 0 Offline = 0 Silent = 0 RegisterAsBrowser= 0 RegisterAsDropTarget= 1 AutoArrange = 0 'False NoClientEdge = 0 'False AlignLeft = 0 'False NoWebView = 0 'False HideFileNames = 0 'False SingleClick = 0 'False SingleSelection = 0 'False NoFolders = 0 'False Transparent = 0 'False ViewID = "{0057D0E0-3573-11CF-AE69-08002B2E1262}" Location = "" End Begin VB.CheckBox chkEnableBizTalkIntegration Caption = "Enable BizTalk Integration" Height = 255 Left = 240 TabIndex = 8 Top = 5280 Width = 2535 End Begin VB.Frame grpEnableBizTalkIntegration Height = 975 Left = 120 TabIndex = 7 Top = 5640 Width = 5775 Begin VB.TextBox txtScheduleFile Height = 375 Left = 1440 TabIndex = 10 Text = "sked:///\vbeventsdemo\Products\ VBCOMConnector\BizTalk\Buyer1.skx" Top = 360 Width = 4095 End Begin VB.Label lblScheduleFile Alignment = 1 'Right Justify Caption = "Schedule File:" Height = 255 Left = 240 TabIndex = 9 Top = 480 Width = 1095 End End Begin VB.CommandButton btnClose Caption = "Close" Height = 375 Left = 5760 TabIndex = 3 Top = 6960 Width = 975 End Begin VB.Frame grpReceivedEvents Caption = "Received Events" Height = 2895 Index = 0 Left = 3000 TabIndex = 6 Top = 2160 Width = 2895 Begin VB.CommandButton btnClear Caption = "Clear" Height = 375 Index = 0 Left = 1680 TabIndex = 2 Top = 2280 Width = 975 End Begin MSComctlLib.ListView lvwReceivedEvents Height = 1695 Left = 120 TabIndex = 1 Top = 360 Width = 2655 _ExtentX = 4683 _ExtentY = 2990 View = 2 LabelWrap = -1 'True HideSelection = -1 'True _Version = 393217 ForeColor = -2147483640 BackColor = -2147483643 BorderStyle = 1 Appearance = 1 NumItems = 2 BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A- 00C0F0283628} Key = "colEventName" Text = "Event Name" Object.Width = 2540 EndProperty BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A- 00C0F0283628} SubItemIndex = 1 Key = "colData" Text = "Data" Object.Width = 6174 EndProperty End End Begin VB.Frame grpSubscriptions Caption = "Subscriptions" Height = 1215 Left = 120 TabIndex = 4 Top = 720 Width = 5775 Begin VB.CheckBox chkPersist Caption = "Persist" Height = 255 Left = 1560 TabIndex = 16 Top = 840 Width = 975 End Begin VB.ComboBox cEventList Height = 315 Left = 1560 Sorted = -1 'True TabIndex = 15 Top = 360 Width = 2295 End Begin VB.CommandButton btnUnsubscribe Caption = "UnSubscribe" Height = 375 Left = 4200 TabIndex = 11 Top = 720 Width = 1095 End Begin VB.CommandButton btnSubscribe Caption = "Subscribe" Height = 375 Left = 4200 TabIndex = 0 Top = 240 Width = 1095 End Begin VB.Label lblEventName Alignment = 1 'Right Justify Caption = "Event Name:" Height = 255 Left = 360 TabIndex = 5 Top = 360 Width = 1095 End End End Attribute VB_Name = "MainForm" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit ' ------------------------------- ** --------------------------------- ' Member Variables ' ------------------------------- ** --------------------------------- Private m_SubscriptionManager As SubscriptionManager Private WithEvents m_OneWorldTransientEventSink As OneWorldTransientEventSink Attribute m_OneWorldTransientEventSink.VB_VarHelpID = -1 Private Sub Combo1_Change() End Sub Private Sub Check1_Click() End Sub Private Sub btnClear_Click(Index As Integer) lvwReceivedEvents.ListItems.Clear End Sub '----------------------------- ** ----------------------------------- ' GetEventTemplate '----------------------------- ** ----------------------------------- Private Sub btnGetEventTemplate_Click() Dim EventName As String Dim EventTemplate As String EventName = cEventList.List(cEventList.ListIndex) 'm_SubscriptionManager.GetEventTemplate EventName, EventTemplate Dim flsObject As New Scripting.FileSystemObject Dim varTemplateFile As TextStream Dim strTemplateFile As String strTemplateFile = "C:\temp\event_template.xml" If Dir(strTemplateFile) = "" Then Set varTemplateFile = flsObject.CreateTextFile (strTemplateFile, False, False) Else Set varTemplateFile = flsObject.OpenTextFile (strTemplateFile,ForWriting, False) End If varTemplateFile.WriteLine EventTemplate varTemplateFile.Close wbEventData.Navigate "c:\temp\event_template.xml" End Sub ' ------------------------------- ** -------------------------------- ' Event Handlers ' ------------------------------- ** -------------------------------- Private Sub Form_Load() Set m_SubscriptionManager = New SubscriptionManager Set m_OneWorldTransientEventSink = New OneWorldTransientEventSink 'EnableBizTalkIntegrationGroup End Sub Private Sub m_OneWorldTransientEventSink_OneWorldEvent(ByVal EventName As String, ByVal Data As String) ' add the event name and payload to the list Dim mTempItem As ListItem Set mTempItem = lvwReceivedEvents.ListItems.Add() mTempItem.Text = EventName 'mTempItem.SubItems(1) = Data Dim flsObject As New Scripting.FileSystemObject Dim varEventFile As TextStream Dim strEventFile As String strEventFile = "C:\temp\eventData.xml" If Dir(strEventFile) = "" Then Set varEventFile = flsObject.CreateTextFile(strEventFile, False, False) Else Set varEventFile = flsObject.OpenTextFile(strEventFile, ForWriting, False) End If varEventFile.WriteLine Data varEventFile.Close wbEventData.Navigate "c:\temp\eventdata.xml" ' send the event to BizTalk (if it is enabled) 'If (chkEnableBizTalkIntegration.Value = Checked) Then 'Dim oBizTalk As BizTalk 'Set oBizTalk = New BizTalk 'oBizTalk.RunSchedule txtScheduleFile.Text, Data ' End If End Sub '----------------------------- ** ----------------------------------- ' GetEventList '----------------------------- ** ----------------------------------- Private Sub btnGetEventList_Click() Dim events As String Dim myValue As String Dim myString As String Set m_SubscriptionManager = New SubscriptionManager m_SubscriptionManager.GetEventList events cEventList.Clear events = "RTSOOUT" myString = events 'Do Until events = "" 'If InStr(1, myString, ":") > 0 Then ' myValue = Left(myString, InStr(1, myString, ":") - 1) ' myString = Mid(myString, InStr(1, myString, ":") + 1) 'Else ' myValue = myString ' events = "" 'End If 'cEventList.AddItem myValue ' Loop cEventList.AddItem myString cEventList.ListIndex = 0 End Sub '----------------------------- ** ----------------------------------- ' Subscribe Event '----------------------------- ** ----------------------------------- Private Sub btnSubscribe_Click() ' subscribe to the named event. Dim EventName As String EventName = cEventList.List(cEventList.ListIndex) If (chkPersist.Value = Checked) Then m_SubscriptionManager.CreatePersistentSubscription EventName, m_OneWorldTransientEventSink Else m_SubscriptionManager.CreateTransientSubscription EventName, m_OneWorldTransientEventSink End If Dim mTempItem As ListItem Set mTempItem = lvwSubscribedEvents.ListItems.Add() mTempItem.Text = EventName End Sub '---------------------------- ** ---------------------------------- ' UnSubscribe Event '---------------------------- ** ---------------------------------- Private Sub btnUnsubscribe_Click() Dim EventName As String EventName = cEventList.List(cEventList.ListIndex) Dim lstItem As ListItem Dim count As Integer Dim found As Boolean count = 0 found = False For Each lstItem In lvwSubscribedEvents.ListItems count = count + 1 If lstItem = EventName Then lvwSubscribedEvents.ListItems.remove (count) GoTo remove found = True End If Next If found = False Then MsgBox "Event Not Subscribed" End If remove: If (chkPersist.Value = Checked) Then m_SubscriptionManager.RemovePersistentSubscription EventName, m_OneWorldTransientEventSink Else m_SubscriptionManager.RemoveTransientSubscription EventName, m_OneWorldTransientEventSink End If End Sub Private Sub chkEnableBizTalkIntegration_Click() 'EnableBizTalkIntegrationGroup End Sub '---------------------------- ** ------------------------------------ ' Clear the Received Events List '---------------------------- ** ------------------------------------ Private Sub btnClear0_Click() ' clear the events from the list lvwReceivedEvents.ListItems.Clear End Sub Private Sub btnClose_Click() m_SubscriptionManager.Logoff Unload Me End End Sub ' ------------------------------ ** --------------------------------- ' Private Functions ' ------------------------------ ** --------------------------------- Private Sub Initialize() ' Create the event sink Set m_OneWorldTransientEventSink = New OneWorldTransientEventSink End Sub Private Sub EnableBizTalkIntegrationGroup() 'Dim blnEnable As Boolean 'blnEnable = (chkEnableBizTalkIntegration.Value = Checked) 'lblScheduleFile.Enabled = blnEnable 'txtScheduleFile.Enabled = blnEnable End Sub
This code is for the BizTalk integration for the received event.
This code sample shows BizTalk subscription:
VERSION 1.0 CLASS BEGIN MultiUse = -1 'True Persistable = 0 'NotPersistable DataBindingBehavior = 0 'vbNone DataSourceBehavior = 0 'vbNone MTSTransactionMode = 0 'NotAnMTSObject END Attribute VB_Name = "BizTalk" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Option Explicit '********************************************************** '***** ExecuteTutorial '***** '***** Purpose: This component is used to exercise '***** the XLANG schedule portion of tutorial accompanying '***** BizTalk Server (this is the Module 1 Tutorial). '***** The component launches the specified schedule '***** file and passes the data file specified '***** to it using MSMQ. '***** '***** NOTE: the source code in this component is a direct '***** adoption of the code found in the Module 1 '***** Tutorial in the BizTalk Server 2000 documentation. '***** The default location for the original version of this '***** source is found in: C:\Program Files\Microsoft '***** BizTalk Server\Tutorial\Schedule\Solution\ '***** ExecuteTutorial.vbp '***** '***** Inputs: '***** Schedule File - Contains the Moniker used to '***** launch the schedule '***** Data File - Contains the location of the '***** XML document to be passed to '***** the schedule for processing. '***** '***** Outputs: '***** Data File - Data file is passed to MSMQ '***** for later retrieval by the schedule. Private g_MSMTxDisp As MSMQ.MSMQTransactionDispenser Private g_MSMQQueue As MSMQ.MSMQQueue Private g_MSMQInfo As MSMQ.MSMQQueueInfo Private g_CurSkedDir As String Private g_CurDataDir As String Private Sub Class_Initialize() Set g_MSMQInfo = CreateObject("MSMQ.MSMQQueueInfo") Set g_MSMTxDisp = CreateObject("MSMQ.MSMQTransactionDispenser") End Sub Public Sub RunSchedule(ByVal strScheduleFile As String, ByVal strData As String) Dim objfs As New FileSystemObject On Error GoTo cmdRunSked_Click_err 'Connect To MSMQ and Remove Any Existing Messages PurgeMSMQ "DIRECT=OS:.\private$\ReceivePoReq" 'Send Selected message to MSMQ ExecuteMSMQ "DIRECT=OS:.\private$\ReceivePoReq", strData 'Start Schedule which reads message from MSMQ ExecuteSchedule strScheduleFile Exit Sub cmdRunSked_Click_err: MsgBox Err.Description & vbCrLf & "Error: " & Err.Number & " (0x" & Hex(Err.Number) & ")", vbCritical, "Error " & Err.Source Err.Clear End Sub Private Sub PurgeMSMQ(ByVal strQueuePath As String) Dim l_MSMQMsg As MSMQMessage On Error GoTo Err_ConnectMSMQ g_MSMQInfo.FormatName = strQueuePath Set g_MSMQQueue = g_MSMQInfo.Open(MQ_RECEIVE_ACCESS, MQ_DENY_NONE) On Error GoTo Err_PurgeMSMQ Do Set l_MSMQMsg = g_MSMQQueue.Receive(, , , 1) Loop While Not l_MSMQMsg Is Nothing Exit Sub Err_ConnectMSMQ: Err.Raise Err.Number, "Connecting To MSMQ", "Could Not Open the MSMQ Queue """ & strQueuePath & """." & vbCrLf & vbCrLf & Err.Description Exit Sub Err_PurgeMSMQ: Err.Raise Err.Number, "Cleaning MSMQ", "Could Not Remove Existing Messages from MSMQ Queue """ & strQueuePath & """." & vbCrLf & vbCrLf & Err.Description Exit Sub End Sub Private Sub ExecuteMSMQ(ByVal strQueuePath As String, DataToQueue As String) Dim QueueMsg As New MSMQMessage Dim strData As String Dim fSend As Boolean Dim txt As TextStream Dim mybyte() As Byte On Error GoTo Err_SendMSMQ g_MSMQInfo.FormatName = strQueuePath Set g_MSMQQueue = g_MSMQInfo.Open(MQ_SEND_ACCESS, MQ_DENY_NONE) mybyte = StrConv(DataToQueue, vbFromUnicode) QueueMsg.Body = DataToQueue Dim MSMQTx As Object Set MSMQTx = g_MSMTxDisp.BeginTransaction QueueMsg.Send g_MSMQQueue, MSMQTx MSMQTx.Commit Set QueueMsg = Nothing Set MSMQTx = Nothing Exit Sub Err_SendMSMQ: Err.Raise Err.Number, "Sending Message To MSMQ", "Could Not Send Message To MSMQ Queue """ & strQueuePath & """." & vbCrLf & vbCrLf & Err.Description Exit Sub End Sub Private Sub ExecuteSchedule(ByVal strSchedule) Dim SendPAQ As Object On Error GoTo Err_ExecSched Set SendPAQ = GetObject(strSchedule) If SendPAQ Is Nothing Then Err.Raise vbObjectError + 1, , "Invalid Schedule Handle Returned." End If Set SendPAQ = Nothing Exit Sub Err_ExecSched: Err.Raise Err.Number, "Starting Schedule", "Could Not Launch the XLANG Schedule" & vbCrLf & "Please verify the path to the SKX file and the path to the data are correct. Also make sure the private queues have been created." & vbCrLf & vbCrLf & Err.Description Exit Sub End Sub
From the Microsoft Windows machine, navigate to COM+ Applications (Control Panel > Administrative Tools > Component Services), and then expand these buttons and folders:
Component Services > Computers > My Computer > COM+ Applications
To add a new application:
On Component Services, select COM+ Applications.
Right-click COM+ Applications, select New, and then select Application.
The COM Application Install Wizard appears. These steps apply to the wizard.
On Install or Create a New Application, select Create an empty application.
On Create Empty Application, enter the name of the application (for example, JDECOMConnectorEvents).
Select an option for Activation Type, and then click Next.
On Set Application Identity, select the Interactive User option, and then click Next.
Click Finish.
A new application, with the name you entered in Step 4, is added to COM+ Applications.
On Component Services, expand the folder for the new application (for example, JDECOMConnectorEvents).
To install the event class:
On Component Services, select Components.
Right-click Components, select New, and then select Component.
The COM Component Install Wizard appears. These steps apply to the wizard.
On Import or Install a Component, select Install new event class(es).
On Select Files to Install, browse to the EventClass.dll on the Microsoft Windows machine.
Select EventClass.dll, and then click Open.
Install new event class appears with information in these fields:
Files to install
Event classes found
Click Next, and then click Finish.
EventClass.dll is successfully added to Component Services.
After you register an event class in the COM+ catalog, you can add subscribers to the event class and subscriptions to the subscribers. For persistent event subscription:
Add a new application for EventSink.
Install the type library component for EventSink.
Add a subscription.
Note:
To add EventSink, follow the steps in the task named To add a new application. The name of the application is EventSink, or a name that you prefer.To install the EventSink component:
On Component Services, expand the folder for the new application (for example, EventSink).
Select Components.
Right-click Components, select New, and then select Component.
The COM Component Install Wizard appears. These steps are for the wizard.
On Import or Install a Component, select Install new component(s).
On Select Files to Install, browse to the EventSink.dll that you previously developed.
Select EventSink.dll, and then click Open.
Install new component appears with information in these fields:
Files to install
Event classes found
Click Next, and then click Finish.
EventSink.dll is successfully added to Component Services.
To add a subscription:
In COM+ Applications, expand these folders:
JDECOMConnectorEvents > Components > EventSink.OneWorldTransientEventSink
Select Subscription.
Right-click Subscription, select New, and then select Subscription.
The COM New Subscription Wizard appears. These steps apply to the wizard.
On Select Subscription Method(s), chose IOWEvent, and then click Next.
If appropriate, select the Use all interfaces for this component option.
On Select Event Class, select the event class (for example, JDEdwards.EventClass.OneWorldEventClass.1), and then click Next.
If multiple EventSink classes have implemented the event interface, then use all event classes that implement that specified interface. If only one EventSink class has implemented the event interface, then just select that specific class.
On Subscription Options, enter the name of the subscription (for example, MySubscription).
In the Options area, select the Enable this subscription immediately option, and then click Next.
Click Finish.
A new subscription, with the name you entered in Step 6, is added to COM+ Services. You must define the name of the event for the subscription.
Right-click the subscription (for example, MySubscription), and then select Properties.
On MySubscription Properties, click the Options tab.
Chose the Enabled option.
In the Filter criteria field, enter the name of the event for which you want a subscription.
Enter all of the events for which you want to subscribe. The filter criteria string supports relational operations (=, ==, !, !=, ~, ~=, <>), nested parentheses, and logical words (AND, OR, and NOT); for example:
EventName=='RTSOOUT' OR EventName==RTPOOUT'
Click OK.