How To Build & Configure A Custom Event Handler

Last published at: June 27th, 2023

FlowWright Enterprise Service Bus (ESB

FlowWright has a powerful ESB that is similar to a traditional publisher-subscriber model, but a one that improves that model to improve performance.  FlowWright utilizes Event definition and Event handler definitions to create a bridge between Events and Event handlers. 


Once Events and Event handlers are defined within FlowWright using the Configuration Manager, Event handlers can be assigned to Events.  A single Event may have any number of Event handlers assigned to that Event.  The same Event handler can be also attached to multiple events. 

Events can be published using the .Net API or the Web service API. 


Once an Event is published to the ESB, assigned event handlers will act on the Event. 

Creating a new Event handler 

Below video shows how to create a custom event handler for FlowWright v10.

Here's the code that was used in the above example:

using FlowWright.API;
using FlowWright.API.ESB;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FW10CustomItems
    public class FWTestHandler : IFWEventHandler
        public void Execute(FWEventContext oContext)
                Hashtable oEventParms = oContext.GetEventParameters();
                oEventParms["eventID"] = oContext.EventID;
                FWProps oProps = oContext.GetProperties();
                oEventParms["eventDefID"] = (oProps["EVENTDEFID"]).ToString();
                oEventParms["createdOn"] = oProps["EVENTCREATEDATETIME"].ToString();
                string eventName = oContext.ESB.GetEventDefinitionName(oProps["EVENTDEFID"].ToString());
                oEventParms["eventName"] = eventName;
                oEventParms["executedOn"] = DateTime.Now.ToString();
                if (!Directory.Exists(@"c:\temp\EventData"))
                string sFormatEventName = eventName.Replace(" """);
                string sFilePath = Path.Combine(@"c:\temp\EventData\", oContext.EventID + "-" + sFormatEventName + ".txt");
                if (File.Exists(sFilePath))
                ArrayList oList = new ArrayList(oEventParms.Keys);
                foreach (string sItem in oList)
                    File.AppendAllText(sFilePath, $"{sItem} - {oEventParms[sItem].ToString()}{Environment.NewLine}");
            catch (Exception ex)
                oContext.MarkEventProcessed(EventStatus.Error, ex.Message);