This appendix contains the following topics:
Section A.2, "Setting Up the COM Connector for Classic Events"
Section A.6, "Implementing JD Edwards EnterpriseOne Interfaces"
Section A.8, "Registering EventSink for Persistent Subscription"
Note:
This chapter is applicable only if you use classic event delivery. Classic event delivery is available if you use JD Edwards EnterpriseOne 8.93 or earlier releases, or if you use JD Edwards EnterpriseOne Tools 8.94 with JD Edwards EnterpriseOne Applications 8.10.Refer to the Guaranteed Events chapters if you use JD Edwards EnterpriseOne Tools 8.94 with JD Edwards EnterpriseOne Applications 8.11 or JD Edwards EnterpriseOne Tools 8.95 or a later Tools release with JD Edwards EnterpriseOne Applications 8.10 or a later Applications release.
The COM connector events solution uses Microsoft's COM+ Events Service. COM+ Events Loosely Coupled Events, which matches and connects publishers and subscribers, is part of the Microsoft Windows 2000 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.
This illustration shows the COM connector architecture for classic events:
Figure A-1 COM Connector Architecture for Classic Events (Software releases prior to JD Edwards EnterpriseOne Tools 8.94)
To support classic event delivery (JD Edwards EnterpriseOne Tools releases prior to 8.94), the COM connector uses the IEO kernel.
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.
This section provides an overview of the process for setting up the COM connector and discusses how to install and set up the COM connector to receive classic events.
These steps provide information for installing the COM connector so that you can receive classic events. Once the COM connector is installed, you set up the COM connector. Setting up the COM server 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.
Use these steps to install and set up the COM connector so that you can receive classic events.
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\JD Edwards 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
Create a new directory called 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 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.
The COM connector is installed and set up. You can 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 both persistent and transient event subscriptions from the JD Edwards EnterpriseOne server. The events are subscribed from the JD Edwards EnterpriseOne server that is specified in the [INTEROP] section of the jdeinterop.ini file. The events are received through the EventListener. The EventListener runs as long as the COM connector is up and running. The COM connector runs as a small globe in the bottom right corner of the Microsoft Windows taskbar.
You must also set up the [EVENTS] section of the jdeinterop.ini file.
Note:
The COM connector does not support subscription of events from multiple JD Edwards EnterpriseOne servers.Logging for COM events is entered in the interopDebug.log file. The error log is interop.log.
This section discusses how to:
Implement a JD Edwards EnterpriseOne interface.
Create a COM+ component.
Log on to the COM connector.
Subscribe to an event.
Add a new application.
Install the event class.
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 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 is the sample code for creating a COM+ 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) Dim flsObject As New Scripting.FileSystemObject Dim varEventFile As TextStream Dim strEventFile As String strEventFile = "C:\temp\eventDataPer.xml". ' change this to a valid directory 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 RaiseEvent OneWorldEvent(EventName, Data) End Sub
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 Explicit Public bLoginEnv As Boolean Private Sub cmdCancel_Click() 'set the global var to false 'to denote a failed login bLoginEnv = False Me.Hide End Sub Private Sub cmdOK_Click() 'check for correct password If txtUserName = "" Or txtenvironment = "" Then bLoginEnv = False MsgBox "Must Enter User Name and Environment to continue" Else bLoginEnv = True Me.Hide End If End Sub
This code sample shows creating the message handler:
Option Explicit Dim conn As New Connector Dim connRole As IConnector2 Dim messageHandler As New messageHandler Dim mHandlerInterface As ImessageHandler Dim lngAccessNumber As Long Public Sub comm_Initialize() Set connRole = conn frmLogin.bLoginEnv = False frmLogin.Show While Not frmLogin.bLoginEnv DoEvents Wend lngAccessNumber = connRole.Login(frmLogin.txtUserName, frmLogin.txtPassword, frmLogin.txtenvironment, frmLogin.txtrole) Set mHandlerInterface = messageHandler End Sub ' NOTE: the code in this module is particular to this prototype. ' Different code would be used in a production version to send ' messages to JD Edwards EnterpriseOne using appropriate communication ' prototocols Public Sub SendSubscriptionToOneWorld(eventName As String, oneworldevent As IOWEvent, mode As Long) mHandlerInterface.SubscribeEvent lngAccessNumber, conn, eventName, oneworldevent, mode End Sub Public Sub SendUnSubscribeToOneWorld(eventName As String, oneworldevent As IOWEvent, mode As Long) mHandlerInterface.UnSubscribeEvent lngAccessNumber, conn, eventName, oneworldevent, mode End Sub Public Sub getEventListFromOneWorld(eventList As String) mHandlerInterface.GetEventList lngAccessNumber, conn, eventList End Sub Public Sub getEventTemplateFromOneWorld(eventName As String, eventTemplate As String) mHandlerInterface.GetEventTemplate lngAccessNumber, eventName, conn, eventTemplate End Sub
This code sample shows event subscription and unsubscribe:
Option Explicit Private m_SubscribedEvents As Collection Private Sub Class_Initialize() Set m_SubscribedEvents = New Collection comm_Initialize End Sub Public Sub GetEventList(eventList As String) getEventListFromOneWorld eventList End Sub Public Sub CreateTransientSubscription(eventName As String, oneworldevent As IOWEvent) SubscribeToOneWorldEvent eventName, oneworldevent, 0 End Sub Public Sub CreatePersistentSubscription(eventName As String, oneworldevent As IOWEvent) SubscribeToOneWorldEvent eventName, oneworldevent, 1 End Sub Public Sub RemoveTransientSubscription(eventName As String, oneworldevent As IOWEvent) UnSubscribeToOneWorldEvent eventName, oneworldevent, 0 End Sub Public Sub RemovePersistentSubscription(eventName As String, oneworldevent As IOWEvent) UnSubscribeToOneWorldEvent eventName, oneworldevent, 1 End Sub Public Sub GetEventTemplate(eventName As String, eventTemplate As String) getEventTemplateFromOneWorld eventName, eventTemplate End Sub Public Sub SubscribeToOneWorldEvent(eventName As String, oneworldevent As IOWEvent, mode As Long) 'Private Function SubscribeToOneWorldEvent(EventName As String) As 'Boolean we've already subscribed if the subscription is in our list Dim alreadySubscribed As Boolean 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 Private Function CollectionContainsString(col As Collection, str As String) Dim colItem As Variant For Each colItem In col If (colItem = str) Then CollectionContainsString = True Exit Function End If Next CollectionContainsString = False End Function Public Sub UnSubscribeToOneWorldEvent(eventName As String, oneworldevent As IOWEvent, mode As Long) Dim alreadySubscribed As Boolean alreadySubscribed = (RemoveFromCollection(m_SubscribedEvents, eventName)) If (alreadySubscribed = False) Then MsgBox "Event Not Subscribed" Else ' and go ahead and subscribe to the event from ' JD Edwards EnterpriseOne SendUnSubscribeToOneWorld eventName, oneworldevent, mode End If ' End If End Sub Private Function RemoveFromCollection(col As Collection, str As String) Dim colItem As Variant Dim count As Integer count = 0 For Each colItem In col count = count + 1 If (colItem = str) Then col.Remove count RemoveFromCollection = True Exit Function End If Next RemoveFromCollection = False End Function
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 option list 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 depicted in separate boxes. The received event is displayed in the window on the right. 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 after registering the COMConnector.dll and MyEventSink.dll.
Option Explicit ' ------------------------------ ** --------------------------------- ' Member Variables ' ------------------------------ ** --------------------------------- Private m_SubscriptionManager As SubscriptionManager Private WithEvents m_OneWorldTransientEventSink As OneWorldTransientEventSink 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 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" 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 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.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 '---------------------------- ** ------------------------------------ ' Clear the Received Events List '---------------------------- ** ------------------------------------ Private Sub btnClear0_Click() ' clear the events from the list lvwReceivedEvents.ListItems.Clear End Sub Private Sub btnClose_Click() Unload Me End End Sub
From a Microsoft Windows 2000 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 Windows 2000 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 To add a new application in the Connectors Guide. 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 press 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.