/// <summary>
 /// 
 /// </summary>
 /// 
 /// <param name="canonicalEvent"></param>
 /// 
 public CanonicalEventArgs(CanonicalEvent canonicalEvent)
 {
     if (canonicalEvent == null)
     {
         throw new ArgumentNullException("canonicalEvent");
     }
     this.canonicalEvent = canonicalEvent;
 }
        /// <summary>
        /// 
        /// </summary>
        /// 
        public override void Listen()
        {
            CanonicalEvent @event = new CanonicalEvent();
            @event.EventType = "StandardEvent";
            @event.Payload = "<message description=\"standard event\" />";

            FireOnEventSourceReceievedEvent(@event);
            Deliver(@event);
        }
        /// <summary>
        /// 
        /// </summary>
        /// 
        /// <param name="@event"></param>
        /// 
        public void Send(CanonicalEvent @event)
        {
            EventItem<CanonicalEvent> item = new EventItem<CanonicalEvent>(@event);
            lock (queue)
            {
                if (Logger.IsDebugEnabled)
                {
                    LogDebug("channel size: {0}.", queue.Count);
                }

                queue.Enqueue(item);
                Monitor.Pulse(queue);

                // disable the following line to make this a blocking channel.
                // Monitor.Wait(queue);
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// 
        /// <param name="@event"></param>
        /// 
        public override void Process(CanonicalEvent @event)
        {
            if (@event == null)
            {
                LogWarn("received null event!");
                return;
            }

            List<IEventRule> rules = EventRuleRegistry.GetRules(@event.EventType);
            if (rules == null)
            {
                return;
            }

            foreach (EventRule rule in rules)
            {
                rule.Invoke(@event);
            }
        }
 /// <summary>
 /// 
 /// </summary>
 /// 
 /// <param name="@event"></param>
 /// 
 protected void FireOnEventNotificationReceievedEvent(CanonicalEvent @event)
 {
     if (OnEventNotificationReceived != null)
     {
         OnEventNotificationReceived.Invoke(this, new CanonicalEventArgs(@event));
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// 
 /// <param name="@event"></param>
 /// 
 public abstract void Notify(CanonicalEvent @event);
 /// <summary>
 /// 
 /// </summary>
 /// 
 /// <param name="@event"></param>
 /// 
 public override void Notify(CanonicalEvent @event)
 {
     Console.WriteLine("firing event notification...");
 }
 /// <summary>
 /// 
 /// </summary>
 /// 
 /// <param name="@event"></param>
 /// 
 public abstract void Execute(CanonicalEvent @event);
 /// <summary>
 /// 
 /// </summary>
 /// 
 /// <param name="@event"></param>
 /// <param name="destination"></param>
 /// 
 protected void Deliver(CanonicalEvent @event)
 {
     if (outputStream != null)
     {
         if (Logger.IsDebugEnabled)
         {
             LogDebug("delivering event type: {0} to destination: {1}.", @event.EventType, destination);
         }
         outputStream.Send(@event);
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// 
 /// <param name="@event"></param>
 /// 
 protected void FireOnEventProcessEndEvent(CanonicalEvent @event)
 {
     if (OnEventProcessEnd != null)
     {
         OnEventProcessEnd.Invoke(this, new CanonicalEventArgs(@event));
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// 
 /// <param name="@event"></param>
 /// 
 public abstract void Process(CanonicalEvent @event);
Exemple #12
0
 /// <summary>
 /// 
 /// </summary>
 /// 
 /// <param name="@event"></param>
 /// 
 protected void FireOnEventSourceDeliveredEvent(CanonicalEvent @event)
 {
     if (OnEventSourceDelivered != null)
     {
         OnEventSourceDelivered.Invoke(this, new CanonicalEventArgs(@event));
     }
 }
Exemple #13
0
        /// <summary>
        /// 
        /// </summary>
        /// 
        /// <param name="@event"></param>
        /// 
        protected virtual void Deliver(CanonicalEvent @event)
        {
            try
            {
                if (!initialized)
                {
                    if (Logger.IsErrorEnabled)
                    {
                        LogError("source has not initialized for destination: {0}.", destination);
                    }
                    throw new EventSourceException("source has not initialized for destination: {0}.", destination);
                }

                outputStream.Send(@event);
                FireOnEventSourceDeliveredEvent(@event);
            }
            catch(Exception exception)
            {
                if (Logger.IsErrorEnabled)
                {
                    LogError("failed to deliver event.", exception);
                }
                FireOnInternalEventSourceExceptionEvent(exception);
            }
        }