I have a service that starts two processes:
1: A message based workflow
2: An event based 'tracker'
The tracker handles several third party APIs that either push data (async) or that we pull data from. I have managed to set this up so that all of the data collected from each API is raised as an event with identical data args. I merge all of the event streams into a single Observable object.
My workflow starts and finds out what id's need to be tracked. It created a sub-workflow for each of the tracker APIs, which set up a subscription to the observable object.
The Observable object, as well as the subscription method are both static in the same static class. This is my 'Event Bridge':
public static class TrackerEventHandler
public static IObservable<TrackerInstanceEventArgs> GetDataObservable()
.FromEvent<TrackerInstanceHandler, TrackerInstanceEventArgs>(handler =>
TrackerInstanceHandler dataHandler = e =>
return dataHandler ;
dataHandler => TrackerInstanceEvents.TrackerInstance += dataHandler ,
dataHandler => TrackerInstanceEvents.TrackerInstance -= dataHandler
public static void SubscribeToTrackerInstanceHandler(int trackerInstanceId, int id, int? workflowId)
GetDataObservable().Where(fd => fd.TrackerInstanceId == trackerInstanceId).Subscribe(o => OnNext(o, id, workflowId));
public static void OnNext(TrackerInstanceEventArgs args, int id, int? workflowId)
public class TrackerInstanceEvents
public static event TrackerInstanceHandler TrackerInstance;
public static void OnTrackerInstance(TrackerInstanceEventArgs args)
if (TrackerInstance != null)
The issue is that OnNext never fires.
SubscribeToTrackerInstanceHandler is called correctly and before the event is triggered. The event does propagate up to the Observable
I created the bridge so that I could link up the two processes (Workflow and 'tracker'). My alternative is to pass an instance of this class to the trackers, but I hoped this would be better.
Am I fundamentally wrong about the use of this static class or am I close?
EDIT - Solved:
GAH - the code works fine >_<
I hadn't set TrackerInstanceEventArgs.TrackerInstanceId
Please forgive my stupidity ^_^