The Event Bus is an extendible piece of the K2 platform that allows third-party events to be raised on a K2 server.
If you want to consume events raised in the K2 environment so that you can perform an action based on an event (for example, write to a text file if a SmartObject is executed), you will need to create a custom Notification Provider as described in the Custom Notification Providers topic.
The difference is that a Notification Provider responds to events and performs an action, while an Event Bus Server raises custom events which a notification provider can then respond to.
The following diagram illustrates the architecture of the Event Bus and shows how 3rd-Party event recorders function in the context of built-in K2 event recorders. All events are funneled into the Generic Client Recorder and queued (using MSMQ or another queuing system) to be processed by the Event Bus.
There are three main components that need to be developed in order to surface events from a 3rd-party server to the Event Bus and to use those events in custom notifications.
Implements: IEventRecorder
Sample code
The Custom Event Recorder provides an interface between the server and the custom recorder. The recorder and interface components are developed separately as custom components. The recorder needs to implement the 3rd-party system interfaces to ensure that the events from that system can be consumed. The recorder also needs to reference the SourceCode.Eventbus.ClientRecorder assembly in order to raise the event via the RaiseEvent method.
Inherits: RuntimeDataResolverBase
The Resolver allows data fields, along with their types and values, to be passed from the custom recorder through to the K2 server. These values can then be used in the custom notification designer as illustrated in the sample below.
Implements: IObjectBrowser
To display the server’s data structure in the K2 Notification Event object browser as shown below, another component needs to be developed. This component will display the objects, events and properties of the 3rd-party server, and needs to implement the IObjectBrowser interface, which is in the SourceCode.Eventbus.Interfaces assembly.
In the solution provided here, a custom recorder is used to capture events from a watched folder on the local server. By default, only new files that have a particular filename cause the recorder to process the event.
The solution is made up of three projects:
The resulting assemblies created when the project is compiled do not ship with K2 blackpearl. These are assemblies that are to be used as samples when creating your own event recorder.
This example assumes Visual Studio is installed on the same machine as the K2 Server.
In K2 blackpearl version 4.6.9, a number of configuration files have been consolidated into a single configuration file to simplify the management of configuration settings. The SourceCode.EventBus.Assemblies.config file has been consolidated into the K2HostServer.exe.Config file, which is located in the \K2 blackpearl\Host Server\Bin folder on the K2 Server. The connection strings previously stored in this file are now retrieved from the K2HostServer.exe.Config file.
When copying code from these examples please make sure that the full XML node is located on the same line. Carriage returns may be inserted by html rendering and will need to be removed.
When the new event recorder is deployed to the server and the necessary .config file changes are made, run the K2 blackpearl Server in console mode from the Start menu to verify it is working. When the example project is built and deployed, the server window will display the following entries when it is finished loading:
If you do not see this message, it could mean that the information messages are not displayed in the console window. To check, browse to C:\Program Files\K2 blackpearl\Host Server\Bin and open the HostServerLogging.config file. In the <ApplicationLevelLogSetting> section of the <ApplicationLevelSettings> section, modify the FileExension LogLocation Active Setting to be True, and the LogLevel Setting to All, as in the following line:
<LogLocationName="FileExtension"Active="True" LogLevel ="All"/>
Save the changes to this file and restart the K2 blackpearl Server from the Start menu.
Then, once you see the message in the server console that the event recorder is loaded, copy the ORD123.txt example file to the C:\FSW\ folder. This will fire an event that will register in the server console.
To further test the example event recorder, browse to K2 Workspace and create a new notification using the data fields from the File System Object Browser. You can test multiple events by creating copies of the example file and changing some of the fields inside the file. The fields can be dragged over to the notification event designer in order to send customized e-mail notifications based on the XML content of the file dropped into the C:\FSW\ folder.
See also: Adding a 3rd Party Server to the Notification Event subsystem
Video | Links | Learn | Support |
No videos found for this article K2 on YouTube
No Additional links found for this article
No self-learning content for this article Try some scenarios...
No relevant support links available for this article
|